EGMap 2.0 Google Maps Extension

Instead of the message displayed by IE, which doesnt say much, could you post the resulting JS code… we may be able to find the bug (if any)

Hi, Antonio. Is there a way to resize, refresh map or render map on some event. My problem is that map is broken when rendered in div with "display: none" property.

The best way to do it is with an IFRAME… the inside page within the IFRAME tag will always display the map…

Thanks a lot ! You mean to create page map.html contains <div id="map"></div> and write in view

<iframe src="map.html"></iframe> ?

And what do you think about this method, maybe it is bad solution ?

I added a bit code in EGmap.php, add additional parameter $initWrapper in registerMapScript() function.

when i render map, I can bind init function on some event:




                 $initWrapper = "$('#tabs').one('tabsshow', function(event, ui) {

                               if (ui.panel.id == 'map'){

                                   {init}

                                }

                 });";


                 $gMap->renderMap('', '', '', CClientScript::POS_LOAD, $initWrapper);



In registerMapScript() function {init} template replaced with init function.:




 if(strpos($initWrapper, '{init}'))

 {

      $initCode = str_replace('{init}', $this->_containerId.'_init();', $initWrapper);

 }

 else

 {

      $initCode = $this->_containerId.'_init();';

 }


  $js = 'function '.$this->_containerId.'_init(){'.PHP_EOL;

			    foreach($init_events as $init_event)

			    {

			      if ($init_event)

			      {

			        $js .= $init_event.PHP_EOL;

			      }

			    }

			    $js .= '

			  }'.PHP_EOL.$initCode.PHP_EOL;



It doesnt look bad…

Hi Antonio ,

I had it as well . maps are not rendered in IE 8 becouse that error .

All your examples have the same problems .

Best regards

Golan

Thanks Golan, unfortunately I do not have any IE 8 at hand right now… any chance for any of you having this issue to point me to the right line? Thanks

Thanks Antonio ,

I “play” with your generated code and found out that it’s working when i replace the init function as follow :


//EGMapContainer1_init();

google.maps.event.addDomListener(window, 'load', EGMapContainer1_init);



Golan

Nice one!!! will update asap

Fixed IE 8 loading issue, thank you all, specially GHADAD

Great extension!

I would like to get the Info Windows to open when the markers are moused over instead of clicked. How would I go about doing that? I’m assuming it has something to do with EGMapEvent, but I’m not sure how to go about doing that.

Thanks for your help in advance!

Sorry to say, it is a good point but at the moment the extension only supports ‘click event’. You will have to modify the lines 235 and 244 of EGMapMarker from ‘click’ to the events you wish to handle.

Ok, I got it to work without editing EGMapMaker.php at all.

I just added the following after declaring a new marker…




$mouseOver = new EGMapEvent("mouseover", "function () {".$gMap->getJsName()."_info_window.setContent(".$info_window->getContent()."); ".$gMap->getJsName()."_info_window.open(".$gMap->getJsName().",".$marker->getJsName().");}", false, EGMapEvent::TYPE_EVENT_DEFAULT);

$marker->addEvent($mouseOver);


$click = new EGMapEvent("click", "function () {window.location.href = '".Yii::app()->request->baseUrl."/index.php/community/view/".$community->id."';}", false, EGMapEvent::TYPE_EVENT_DEFAULT);

$marker->addEvent($click);



The $mouseOver variable must be defined after


$marker = new EGMapMarker($community->latitude, $community->longitude);

to keep $marker->getJsName() from producing an error.

The click event just links the marker to that community’s view page when clicked.

As I said, this works without editing EGMapMarker.php, however for it to work a bit more smoothly you can comment out lines 233 - 240 and line 244.

I’m not sure if this is the best way to do this, but it works.

Hey Antonio, awesome plugin, I saw the updated 2.2 today and used it in our current code - works fantastically well. I follow you on twitter and also use your website, its truly a wonderful and informative one!

Now my question (as there is always one!);

I also want to place the current location of the user on the map. The user will be using an iPhone to show the webpage that has the map on it and want to be able to show the current location of the user and the destination

Is this possible and how?

Ideally I want two things…

1/ to be able to have the current location update as the user is moving towards destination

2/ have a routed path - such as in the iPhone Maps application…

If this is not possible, possibly a link to allow it to jump to the iPhone Maps application.

thank you for a great extension .

Seconded… been using a slightly modified version 2.0 for a while and it’s been a great help in our projects.

Just a heads-up about a small issue with your GitHub repo - the space at the end of the validators stops Windows users from cloning it, giving the following message:


fatal: cannot create directory at 'validators /EABARoutingNumberValidator': No such file or directory

wow! What an issue!.. thanks for that! will update asap

Edit: DONE! Thank you so much Crowze

In EGMapClient.php, line 242:


curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

Because I have an open_basedir restriction, this gives an error message:

CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set

Is it possible to change line 242 to


@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

to suppress this error message?

Will do asap… thank you very much BertB for the information…

I have solved this issue, new version on GitHub. Going to upload asap…

Cheers and thanks again