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

Jump to content

  • (13 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 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

#21 User is offline   dr.simple 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 03-January 11

Posted 06 January 2011 - 12:14 PM

Thank you for your fast reply.

View PostAntonio Ramirez, on 06 January 2011 - 11:37 AM, said:

If you are able to do so, and include some classes to the library, please let me know. I would love to include them into the extension!

Of course :)
0

#22 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 10 January 2011 - 09:43 AM

Great extension!!!

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

Thanks,
Dan
0

#23 User is online   Antonio Ramirez 

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

Posted 10 January 2011 - 01:48 PM

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

This post has been edited by Antonio Ramirez: 10 January 2011 - 02:55 PM

¿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

#24 User is online   Antonio Ramirez 

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

Posted 10 January 2011 - 01:52 PM

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!

This post has been edited by Antonio Ramirez: 10 January 2011 - 02:55 PM

¿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

#25 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 11 January 2011 - 08:48 AM

View PostAntonio Ramirez, on 10 January 2011 - 01:48 PM, said:

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


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

Cheers
0

#26 User is online   Antonio Ramirez 

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

Posted 11 January 2011 - 09:12 AM

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.c...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

This post has been edited by Antonio Ramirez: 11 January 2011 - 09:32 AM

¿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

#27 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 11 January 2011 - 09:33 AM

View PostAntonio Ramirez, on 10 January 2011 - 01:52 PM, said:

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!


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
0

#28 User is online   Antonio Ramirez 

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

Posted 11 January 2011 - 10:15 AM

View Postbitmatix, on 11 January 2011 - 09:33 AM, said:

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().");"));


by changing this line and adding the above mentioned javascript you can clear all markers and open infowwindow from the map, and there is always only 1 infowindow if ou click on any marker.

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.
¿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

#29 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 11 January 2011 - 10:20 AM

View PostAntonio Ramirez, on 11 January 2011 - 10:15 AM, said:

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
0

#30 User is online   Antonio Ramirez 

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

Posted 11 January 2011 - 11:14 AM

Now I understand...
¿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

#31 User is online   Antonio Ramirez 

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

Posted 11 January 2011 - 11:52 AM

View Postbitmatix, on 11 January 2011 - 10:20 AM, said:

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


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
¿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

#32 User is offline   Khan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-September 10

Posted 12 January 2011 - 09:32 AM

View PostAntonio Ramirez, on 11 January 2011 - 11:52 AM, said:

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.
0

#33 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 12 January 2011 - 09:43 AM

View PostKhan, on 12 January 2011 - 09:32 AM, said:

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>

0

#34 User is online   Antonio Ramirez 

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

Posted 12 January 2011 - 09:58 AM

Is this what you want?

http://gmaps-samples...om-markers.html
¿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

#35 User is offline   Khan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-September 10

Posted 13 January 2011 - 07:51 AM

<?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
0

#36 User is online   Antonio Ramirez 

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

Posted 13 January 2011 - 08:24 AM

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
¿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

#37 User is online   Antonio Ramirez 

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

Posted 22 January 2011 - 02:54 PM

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

Attached File(s)


¿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

#38 User is online   Antonio Ramirez 

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

Posted 24 January 2011 - 07:00 AM

Glad to announce version 1.8 is just uploaded. I was quite fast writing the code, so please, bug reports, feedback?
¿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

#39 User is online   Antonio Ramirez 

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

Posted 24 January 2011 - 09:15 PM

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)

Attached File(s)


¿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

#40 User is online   Antonio Ramirez 

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

Posted 25 January 2011 - 02:43 PM

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
¿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

Share this topic:


  • (13 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 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