Yii Framework Forum: EGMap 2.0 Google Maps Extension - Yii Framework Forum

Jump to content

  • (13 Pages)
  • +
  • « First
  • 8
  • 9
  • 10
  • 11
  • 12
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EGMap 2.0 Google Maps Extension Objet-oriented PHP abstraction to the Google Maps API to ease the proc Rate Topic: ***** 5 Votes

#181 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 03 February 2012 - 03:26 AM

View PostAntonio Ramirez, on 03 February 2012 - 02:58 AM, said:

The problem is that the layer was hidden at first and then, when is shown the map doesnt render properly. Is a common problem... Normally, firing its resize method works, being on a CJuiDIalog you will also have to set a small delay (use setTimeout)

Another solution would be to have an IFRAME inside the CJuiDialog content with the src attribute pointing to the page that renders the map... you wont have problems with it.

To get the Id just use the getJsName() method of the map object.


Thanks for your reply but I think in iframe, google is preventing the loading of the map. and using the resize method and delay, still not working. This is the code the dialog trigger
    
<?php echo CHtml::ajaxButton(_t('Google Map'), '#', array('success'=>"js:function(){ 
        google.maps.event.trigger(map_location, 'resize');
        setTimeout( function() {
          $('#mapdialog').dialog('open').parent().css({position:'fixed'});
        }, 5000 );
       }"), array('class'=>btn)); ?>

0

#182 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 03 February 2012 - 04:05 AM

View Postbutching, on 03 February 2012 - 03:26 AM, said:

Thanks for your reply but I think in iframe, google is preventing the loading of the map. and using the resize method and delay, still not working. This is the code the dialog trigger
    
<?php echo CHtml::ajaxButton(_t('Google Map'), '#', array('success'=>"js:function(){ 
        google.maps.event.trigger(map_location, 'resize');
        setTimeout( function() {
          $('#mapdialog').dialog('open').parent().css({position:'fixed'});
        }, 5000 );
       }"), array('class'=>btn)); ?>



Try this
<?php echo CHtml::ajaxButton(_t('Google Map'), '#', array('success'=>"js:function(){ 
       $('#mapdialog').dialog('open').parent().css({position:'fixed'});
        setTimeout( function() {
           google.maps.event.trigger(map_location, 'resize');
        }, 1000 );
       }"), array('class'=>btn)); ?>


You resized the map before the layer was shown, it has to be done after...
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#183 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 03 February 2012 - 04:48 AM

View PostAntonio Ramirez, on 03 February 2012 - 04:05 AM, said:

Try this
<?php echo CHtml::ajaxButton(_t('Google Map'), '#', array('success'=>"js:function(){ 
       $('#mapdialog').dialog('open').parent().css({position:'fixed'});
        setTimeout( function() {
           google.maps.event.trigger(map_location, 'resize');
        }, 1000 );
       }"), array('class'=>btn)); ?>


You resized the map before the layer was shown, it has to be done after...


Yeah that was wrong hehe now it's working!

Many Thanks ! great extension with great developer nice!

btw does this extension include autocomplete of places? when searching?
0

#184 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 03 February 2012 - 06:19 AM

View Postbutching, on 03 February 2012 - 04:48 AM, said:

Yeah that was wrong hehe now it's working!

Many Thanks ! great extension with great developer nice!

btw does this extension include autocomplete of places? when searching?


No, it doesnt, but that could be a great addition to the extension... volunteer?

Thanks for your words

Cheers
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#185 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 06 February 2012 - 02:52 AM

View PostAntonio Ramirez, on 03 February 2012 - 06:19 AM, said:

No, it doesnt, but that could be a great addition to the extension... volunteer?

Thanks for your words

Cheers


I would loved to volunteer but im not expert in php

I attached the class I created and include this function in EGMap.php
	
public function addAutocomplete($inputId = null)
{
    Yii::app()->getClientScript()->registerScriptFile('http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places');
    
    if ($inputId === null)
      $autocomplete = new EGMapAutocomplete();
    else
      $autocomplete = new EGMapAutocomplete($inputId);

    $this->resources->add('autocompletes', new CTypedList('EGMapAutocomplete'));    
    $this->resources->itemAt('autocompletes')->add($autocomplete);
}


and this code to activate the autocomplete
$gMap->addAutocomplete();


but the thing is the jscode inside the class is not generating. For sure Im missing something here ehehe so you may wanna look if you have time thanks

here's my reference from maps places autocomplete http://code.google.c...ng_autocomplete

cheers

Attached File(s)


0

#186 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 06 February 2012 - 03:16 AM

Will have a look at it...

It doesn't write cuz it is not registered... Seems an interesting addition, will look onto the best way to add it to the library. Thanks.

PS: The google maps api is already registered, what we need to add is the 'libraries=places' parameter to the insertion, thus, the use of EGMapAutocomplete class maybe not a right way to do it. Will keep you updated.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#187 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 06 February 2012 - 03:32 AM

View PostAntonio Ramirez, on 06 February 2012 - 03:16 AM, said:

Will have a look at it...

It doesn't write cuz it is not registered... Seems an interesting addition, will look onto the best way to add it to the library. Thanks.

PS: The google maps api is already registered, what we need to add is the 'libraries=places' parameter to the insertion, thus, the use of EGMapAutocomplete class maybe not a right way to do it. Will keep you updated.


I added this function
public function getAutocompleteJs()
	{
		$return = '';
		if (null !== $this->resources->itemAt('autocomplete'))
		{
			foreach ($this->resources->itemAt('autocomplete') as $autocomplete)
			{
				$return .= $autocomplete->toJs($this->getJsName());
				$return .= "\n      ";
			}
		}
		return $return;
	}

and this line
$init_events[] = $this->getAutocompleteJs();
in
public function registerMapScript


the jscode of Autocomplete now displays but it says google.maps.places is undefined. is this because you say that its not registered? in the reference of google you only need this
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"></script>
to run the api and I already have it and it seems that they dont recognize it!?

I used EGMapAutocomplete for them to have an option to used autocomplete or not and just to separate the code from EGMap.php ehehe

hmm ok Ill wait for your update. It's exciting ehehe.
0

#188 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 06 February 2012 - 03:46 AM

If you look at the registerMapScript function you will realize that the API script is registered without the 'libraries' param (line 488-494 of EGmap.php), add this to $params variable.

$params .= '&libraries=places';


Should work.

Nevertheless, I realized that places could be a great addition to EGMap and autocomplete is just a small thing onto the places functionality. I remember adding it long time a go but I got 'trap' by current projects. I will add it as soon as I have time :)
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#189 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 06 February 2012 - 04:03 AM

View PostAntonio Ramirez, on 06 February 2012 - 03:46 AM, said:

If you look at the registerMapScript function you will realize that the API script is registered without the 'libraries' param (line 488-494 of EGmap.php), add this to $params variable.

$params .= '&libraries=places';


Should work.

Nevertheless, I realized that places could be a great addition to EGMap and autocomplete is just a small thing onto the places functionality. I remember adding it long time a go but I got 'trap' by current projects. I will add it as soon as I have time :)


Hey It works! thanks a lot!

there is a little issue .. since I rendered it through dialog.. I see the "Enter a location" which is generated by the autocomplete api but the dropdown autocomplete is not showing.. maybe it's the same with my previous issue with the map displaying broken on the dialog but already fixed with setTimeOut() and resize, is it the div/css of the dropdown?

thanks again
0

#190 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 06 February 2012 - 04:24 AM

View Postbutching, on 06 February 2012 - 04:03 AM, said:

Hey It works! thanks a lot!

there is a little issue .. since I rendered it through dialog.. I see the "Enter a location" which is generated by the autocomplete api but the dropdown autocomplete is not showing.. maybe it's the same with my previous issue with the map displaying broken on the dialog but already fixed with setTimeOut() and resize, is it the div/css of the dropdown?

thanks again


check the z-index of the layer, i am sure that is the issue...
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#191 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 06 February 2012 - 04:41 AM

View PostAntonio Ramirez, on 06 February 2012 - 04:24 AM, said:

check the z-index of the layer, i am sure that is the issue...


Yes its the z-index.. its below the z-index of the dialog box. thanks again!

cheers
0

#192 User is offline   compugator 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 01-May 11

Posted 21 March 2012 - 08:39 AM

View Postbossm4, on 09 January 2012 - 07:44 PM, said:

Hello!

I'm triying to load an EGMap on a partial view. This is my code:

This is the ajax button which calls the action loadmap:
<?php echo CHtml::ajaxsubmitButton ("Press for geolocation",
                              CController::createUrl('organization/loadmap'), 
                              array('update' => '#formMap'));
            ?>


The action loadmap:
$this->renderPartial('_loadMap',array('model'=>$model),false,true);


And finally the partial view:
<div id="formMap">
    <?php
        
        $address = $model->address . ", " . City::model()->giveLocation($model->cityID);
        
        echo $address;
    
        Yii::import('ext.EGMap.*');
        
        $gMap = new EGMap();
        $gMap->zoom = 5;
        $gMap->width = '100%';
        $gMap->height = 200;

        $mapTypeControlOptions = array(
            'position'=> EGMapControlPosition::RIGHT_TOP,
            'style'=>EGMap::MAPTYPECONTROL_STYLE_DEFAULT,
        );

        $gMap->mapTypeId = EGMap::TYPE_HYBRID;
 
        $gMap->mapTypeControlOptions= $mapTypeControlOptions;
 
        // Create geocoded address
        $geocoded_address = new EGMapGeocodedAddress($address);
        $geocoded_address->geocode($gMap->getGMapClient());
 
        // Center the map on geocoded address
        $gMap->setCenter($geocoded_address->getLat(), $geocoded_address->getLng());
 
        // Add marker on geocoded address
        $gMap->addMarker(
            new EGMapMarker($geocoded_address->getLat(), $geocoded_address->getLng())
        );
 
        $gMap->renderMap();

    ?>
</div>


The website loads the div but not the map. Any suggestion???

Thank you so much!!!


Did anybody ever answer this? I am having the same problem where my ajax update will not show the map.
1

#193 User is offline   kukuoc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 26-March 12

Posted 26 March 2012 - 02:59 AM

Thanks for sharing
0

#194 User is offline   butching 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 05-July 10

Posted 30 March 2012 - 03:01 AM

I read again the thread and it seems that they're adding multiple cluster on the js itself and not on the extension that you made. In your extension, adding clusterer is possible but you can only add one right?

Is there a way to add multiple clusterer in your extension?

thanks
0

#195 User is offline   casperskou 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 06-April 12

Posted 24 April 2012 - 03:13 AM

Hello

I'm trying to make the geocoder position-capturing function, in a dialog window..

But everytime i enable the $marker->capturePosition() it's showing in the original view instead of in the dialog..
I think it has something to do with the:
if (!in_array('nocallback', $options)){
  $this->addCallback('function(result){captureMarkerPosition(result);}');
}


but i am not familar enough with javascript to figure out how to fix this problem.. :/


Futhermore i also got the problem that the map is not fully rendering..
I call the dialog with:
<?php echo CHtml::link('<img src="'.Yii::app()->request->baseUrl.'/images/icons/dsa.png" alt="hej" />', '#', array('onclick'=>"{addGeocode(); $('#dialogGeocodepicker').dialog('open');}")); ?>

and then just:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array( // the dialog
    'id'=>'dialogGeocodepicker',
    'options'=>array(
        'title'=>'Geocode Picker',
        'autoOpen'=>false,
        'modal'=>true,
        'width'=>550,
        'height'=>470,
    ),
)); 

echo $this->renderPartial('_geocodepicker', array('landmark'=>$landmark)); 

$this->endWidget();?>



Would very much appreciate some help on these issues - thank you very much..
And thanks for a nice extension, which i will love as soon as i get these problems fixed, heh.. :)
0

#196 User is offline   gezzeg 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-December 10

Posted 02 May 2012 - 11:25 PM

View Postbutching, on 06 February 2012 - 02:52 AM, said:

I would loved to volunteer but im not expert in php

I attached the class I created and include this function in EGMap.php
	
public function addAutocomplete($inputId = null)
{
    Yii::app()->getClientScript()->registerScriptFile('http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places');
    
    if ($inputId === null)
      $autocomplete = new EGMapAutocomplete();
    else
      $autocomplete = new EGMapAutocomplete($inputId);

    $this->resources->add('autocompletes', new CTypedList('EGMapAutocomplete'));    
    $this->resources->itemAt('autocompletes')->add($autocomplete);
}


and this code to activate the autocomplete
$gMap->addAutocomplete();


but the thing is the jscode inside the class is not generating. For sure Im missing something here ehehe so you may wanna look if you have time thanks

here's my reference from maps places autocomplete http://code.google.c...ng_autocomplete

cheers


Hi, thanks for adding the autocomplete function.

To use this function just add this files to the EGMap directory inst it?
0

#197 User is offline   gezzeg 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-December 10

Posted 03 May 2012 - 03:41 AM

Basicly how to call $gMap->addAutocomplete(); at view?
0

#198 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 05 May 2012 - 01:17 PM

View Postcasperskou, on 24 April 2012 - 03:13 AM, said:

Hello

I'm trying to make the geocoder position-capturing function, in a dialog window..

But everytime i enable the $marker->capturePosition() it's showing in the original view instead of in the dialog..
I think it has something to do with the:
if (!in_array('nocallback', $options)){
  $this->addCallback('function(result){captureMarkerPosition(result);}');
}


but i am not familar enough with javascript to figure out how to fix this problem.. :/


Futhermore i also got the problem that the map is not fully rendering..
I call the dialog with:
<?php echo CHtml::link('<img src="'.Yii::app()->request->baseUrl.'/images/icons/dsa.png" alt="hej" />', '#', array('onclick'=>"{addGeocode(); $('#dialogGeocodepicker').dialog('open');}")); ?>

and then just:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array( // the dialog
    'id'=>'dialogGeocodepicker',
    'options'=>array(
        'title'=>'Geocode Picker',
        'autoOpen'=>false,
        'modal'=>true,
        'width'=>550,
        'height'=>470,
    ),
)); 

echo $this->renderPartial('_geocodepicker', array('landmark'=>$landmark)); 

$this->endWidget();?>



Would very much appreciate some help on these issues - thank you very much..
And thanks for a nice extension, which i will love as soon as i get these problems fixed, heh.. :)


As stated in previous posts, you need to call the map resize in order to render properly... cheers
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#199 User is offline   aaadkins 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-October 11

Posted 10 May 2012 - 08:58 PM

I am just starting to learn this extension which is really nice by the way and I am trying to go through all of the examples that are listed but I am running into a problem with the advanced example that Johnatan has posted. I keep getting an error that says $items is undefined. Does anyone know where this is supposed to be declared or what is is supposed to reference?
$dragevent = new EGMapEvent('dragend', "function (event) { $.ajax({
                                            'type':'POST',
                                            'url':'".$this->createUrl('catalog/savecoords').'/'.$items->id."',
                                            'data':({'lat': event.latLng.lat(), 'lng': event.latLng.lng()}),
                                            'cache':false,
                                        });}", false, EGMapEvent::TYPE_EVENT_DEFAULT);


Also, I know he mentions that $map is model of a database table used to save coordinates but can anyone tell me or show me what exactly this model and database table contain? Thanks
0

#200 User is offline   dulharjo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 29-April 12

Posted 11 May 2012 - 03:29 AM

anyone can show me how to use MYSQL inside EGmap?
0

Share this topic:


  • (13 Pages)
  • +
  • « First
  • 8
  • 9
  • 10
  • 11
  • 12
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users