Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the Title on a Google Maps Marker

Given a google maps marker how can I change the title ?

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

I have tried

_marker.setTitle("new title");  

and

_marker.title = "new title";

but the title is still "old title"

like image 378
David Moorhouse Avatar asked Jul 20 '11 11:07

David Moorhouse


2 Answers

In API v3 it would be:

marker.setTitle('new title');
like image 159
Ibcus Avatar answered Nov 11 '22 02:11

Ibcus


Googling your question suggests this:

The information is not held in the marker.title property. Where it is held varies from release to release. In v2.129e it's held in marker.$.title. Also, the information is only processed when you addOverlay the marker. So in v2,129e you can write: marker.$.title = "updated title"; map.removeOverlay(marker); map.addOverlay(marker);

(original answer by Mike Williams of Blackpool, UK)

like image 43
Richard Inglis Avatar answered Nov 11 '22 02:11

Richard Inglis