EGMap 2.0 Google Maps Extension

Thank you for your fast reply.

Of course :)

Great extension!!!

Could you please show me how to use custom icon with this extensions?

Thanks,

Dan

very, very easy (please update to version 1.6):

With direct URL (same goes for ‘shadow’ property)





Yii::import('ext.gmaps.*');

	$gMap = new EGMap();

	$gMap->setZoom(13);

	$gMap->setCenter(39.721089311812094, 2.91165944519042);

	 

	// Create GMapInfoWindow

	$info_window = new EGMapInfoWindow('<div>I was living here as a kid!</div>');

	 

	// Create marker

	$marker = new EGMapMarker(39.721089311812094, 2.91165944519042, array('title' => '"My Town"','icon'=>'"http://google-maps-icons.googlecode.com/files/gazstation.png"'));

	$marker->addHtmlInfoWindow($info_window);

	$gMap->addMarker($marker);

	$gMap->renderMap();




with EGMarkerImage class:




Yii::import('ext.gmaps.*');

	$gMap = new EGMap();

	$gMap->setZoom(13);

	$gMap->setCenter(39.721089311812094, 2.91165944519042);

	 

	// Create GMapInfoWindow

	$info_window = new EGMapInfoWindow('<div>I was living here as a kid!</div>');


        // Creating new Image for a custom Icon -google maps v3

	$icon = new EGMapMarkerImage("http://google-maps-icons.googlecode.com/files/gazstation.png");

	$icon->setSize(32, 37);

	 

	// Create marker

	$marker = new EGMapMarker(39.721089311812094, 2.91165944519042, 

                                  array('title' => '"My Town"',

                                             'icon'=>$icon)); // icon

	$marker->addHtmlInfoWindow($info_window);

	$gMap->addMarker($marker);

	$gMap->renderMap();



Cheers

I still have to re-build the Marker so it fits google map v3 api.

Edit: Done, new version on the way!

Edit: Version updated, please download to version 1.6!

Great, but it seems like the setOrigin or setAnchor functions doesn’t work :(

Cheers

Thanks for your feedback. Solving the issue

Edit: Could you please drop your resulting Javascript here? Are you sure is not dropping it like: http://blog.mridey.com/2010/03/using-markerimage-in-maps-javascript.html

Update: You are right, there is a bug on line 277 of EGMarkerImage class. Please correct the issue before update the extension. Thanks for your positive feedback buddy.

// remove this on line 277 of EGMarkerImage class, function anchorToJs

$this->getName().

should be like this:

$anchor = ‘new google.maps.Point(’.$this->getAnchorX().’,’.$this->getAnchorY().’)’;

Update: I have uploaded version update

It would be nice, if you could insert the following javascript code into your "registerScriptMap" function (EGMap.php on line 551):




        google.maps.Map.prototype.markers = new Array();


        google.maps.Map.prototype.getMarkers = function() {

          return this.markers;

        };


        google.maps.Map.prototype.clearMarkers = function() {

          if (infowindow)

            infowindow.close();

          for(var i=0; i<this.markers.length; i++)

          {

            this.markers[i].setMap(null);

          }

          this.markers = new Array();

        };


        google.maps.Marker.prototype._setMap = google.maps.Marker.prototype.setMap;


        google.maps.Marker.prototype.setMap = function(map) {

          if (map)

          {

            map.markers[map.markers.length] = this;

          }

          this._setMap(map);

        }



EGMap.php on line 157:




$this->addGlobalVariable('infowindow','null');



this code is for deleting all markers on map by calling:

YOUR_MAP_NAME.clearMarkers();

EDIT:

in EGMapMarker.php change line 288 to:




$this->addEvent(new EGMapEvent('click','if (infowindow) infowindow.close(); infowindow = '.$this->info_window->getName().'; '.$this->info_window->getName().".open(".$map_js_name.",".$this->getName().");"));



this changes the behavior of the infowindow. there should always be only 1 opened infowindow

cheers

The idea is not bad, but how do you render the content of that infowindow per marker? where it should be stored? There is an after_init parameter in renderMapScript and renderMap function that allows you to render any custom script commands.

It doesn’t change anything about adding an infowindow. All stays the same, but the generated code looks like this:




    info_window6 = new google.maps.InfoWindow({

      content: "Tauentzienstrasse 19/19a<br />10789 Berlin"

    });


    var marker6 = new google.maps.Marker({

      map: map4d2c77428dfdc,

      position: new google.maps.LatLng(52.502562, 13.339489),

    });

    google.maps.event.addListener(marker6, "click", function() {if (infowindow) infowindow.close(); infowindow = info_window6; info_window6.open(map4d2c77428dfdc,marker6);});


    info_window7 = new google.maps.InfoWindow({

      content: "Test 123<br />12345 Berlin"

    });


    var marker7 = new google.maps.Marker({

      map: map4d2c769f137f0,

      position: new google.maps.LatLng(52.4517345, 13.3151777),

    });

    google.maps.event.addListener(marker7, "click", function() {if (infowindow) infowindow.close(); infowindow = info_window7; info_window7.open(map4d2c769f137f0,marker7);});




All markers work like before, except that any opened infowindow gets closed before the new one gets opened

Now I understand…

Support added bitmatix, now if info_window is set by a user, global variable for specific map (where the map renders) includes global info window reference automatically.

Thank you very much for your feedback

Hi guys thanks for great Extension, I just did implement and it’s work fine but I need one more feature to add in my project which is related to this extension.

I have three Markers on map and for those Markers, I would like to point out each Marker link like…"Map it" some where on view if a user clik on "Map it" link then it will pop up that Marker and open the marker text window.

I hope to get response soon,

Have a good day.

If you look in the generated javascript, you could find out in which variables your info windows are stored. After that you can do the following:




<a href="#" onclick="info_window1.open(map1,marker1); return false;">Map it</a>

<a href="#" onclick="info_window2.open(map1,marker2); return false;">Map it</a>

<a href="#" onclick="info_window3.open(map1,marker3); return false;">Map it</a>



Sorry, my fault. It has to be:




<a href="#" onclick="info_window1.open(map1,map1.markers[0]); return false;">Map it</a>

<a href="#" onclick="info_window2.open(map1,map1.markers[1]); return false;">Map it</a>

<a href="#" onclick="info_window3.open(map1,map1.markers[2]); return false;">Map it</a>



Is this what you want?

http://gmaps-samples-v3.googlecode.com/svn/trunk/sidebar/random-markers.html


<?php	

	Yii::import('ext.gmaps.*');


	$gMap = new EGMap();

	$gMap->setWidth(625);

	$gMap->setHeight(400);

	$gMap->setZoom(10);

	

foreach($deals as $post): 

	$sample_address = $post->red_address ." ".$post->red_city ." ".$post->red_state ." ". $post->red_zip ." ". $post->red_cont_code ;

	$geocoded_address = new EGMapGeocodedAddress($sample_address);

	$geocoded_address->geocode($gMap->getGMapClient());

	

	 // Create GMapInfoWindow

	$info_window = new EGMapInfoWindow('<br /><div><strong>'.$post->title.'</strong></div><br />Location :'.$sample_address.'<br /> <br /><a href=/deals/view?id=' .$post->id .'><img src=' .$baseUrl.'/static/images/systemimages/vdtls.png></a><br /> <br />');

	$gMap->setCenter($geocoded_address->getLat(), $geocoded_address->getLng());


	// Create new marker

	$marker = new EGMapMarker($geocoded_address->getLat(), $geocoded_address->getLng(), 

						array('title' => '"'.$post->title.'"'));

								// 'icon'=>$icon)); // icon

								 

	$marker->addHtmlInfoWindow($info_window);

	$gMap->addMarker($marker);

	?>


	<h3> <a href="/deals/view?id=<?php echo $post->id; ?>"  title="<?php echo $post->title ;?>"><?php echo $post->title ;?></a></h3>											 

	<a href="#" onclick="info_window.open(gMap,gMap.markers[2]); return false;">Map it</a>				


<?php endforeach; 

			

$gMap->appendMapTo('#map2_container');

$gMap->renderMap();?>



I give try to above codes but doesn’t work please have a look and I’m sure Im handling wrong on some how.

Antonio Ramirez, the link you send me I need to have like that, the source code for that link was a too much puzzle for me as Im not JScript expert, is there any simple way to handle that task.

As I query a table for records and if found then put in loop to display all rows and during this process I generate Map Marker for each row and would like to have "Map it" for that Marker during row loop.

I’ll try to handle some how if not please if you have some solution let me know, I’ll be grateful to all of you guys.

Thanks and Have a nice day.

Jan

Hi Khan,

I have analyzed your feature request and I think it is possible. It is all created by attaching an event trigger to every marker variable. Stay tunned, as soon I have time I will implement this feature.

Cheers

Included support for keyDragZoom utility, please see atached image ( A ).

I have included the option of labeled Markers, please see attached image ( B ).

Included support for marker clusterer utility, please see attached image ( C )

Lots of minor bug fixes and code performance

Stay tunned for v.1.8. I will upload it as soon as I write its comments.

Cheers

Glad to announce version 1.8 is just uploaded. I was quite fast writing the code, so please, bug reports, feedback?

Code improving… 3AM here. You will be pleased with version 1.9. Attached an image inside the project I am working on (Full reverse GeoLocator)

I have updated the extension (version 2.0) but it is a major change. I have modified the whole library to support magic getters and setters for all array options of the objects. So, in order to avoid version conflicts I will upload it, when finished, to my blog or GitHub or even Google Code as the extension is getting quite big.

Also, KML support is on the way.

Cheers