Name Changes on Google Maps Markers

Given the google map marker, how can I change the title?

var _marker = new google.maps.Marker({ position: aPoint, map: mmap, title:"old title" }); 

I tried

 _marker.setTitle("new title"); 

and

 _marker.title = "new title"; 

but the name is still the "old name"

+7
source share
3 answers

For your question, this is suggested:

Information is not stored in the marker.title property. Where it varies from release to release. In v2.129e, it was contained in a token. $. title. In addition, information is only processed when an Overlay marker is added. So, in v2.129e you can write: marker. $. title = "updated title"; map.removeOverlay (marker); Map.addOverlay (marker);

(original answer by Mike Williams from Blackpool, UK)

+2
source

In API v3, this will be:

 marker.setTitle('new title'); 
+14
source

For the new version of the google map api, you can use setTitle () to change the name of any existing marker
Example

 marker.setTitle("new title"); 
0
source

All Articles