更改Google地图标记上的标题

时间:2011-07-20 11:51:44

标签: google-maps-api-3 google-maps-markers

考虑到Google地图标记,我该如何更改标题?

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

我试过了

_marker.setTitle("new title");  

_marker.title = "new title";

但标题仍然是“旧标题”

3 个答案:

答案 0 :(得分:15)

在API v3中,它将是:

marker.setTitle('new title');

答案 1 :(得分:2)

Google搜索您的问题建议this

  

该信息未保存在marker.title属性中。在哪儿   持有的版本因版本而异。在v2.129e它被保留了   标记。$。冠军。   此外,只有在addOverlay标记时才会处理信息。   所以在v2,129e你可以写:   标记。$。title =“更新标题”;   map.removeOverlay(标记);   map.addOverlay(标记);

(英国布莱克浦的Mike Williams原创回答)

答案 2 :(得分:0)

对于新版Google地图API,您可以使用 setTitle()来更改任何现有标记的标题
实施例

marker.setTitle("new title");