0
我想填充谷歌地图标记图标上的小标注。标题似乎并没有这样做。我阅读了文档,但找不到任何东西。javascript谷歌地图API - 更改标记标题
https://developers.google.com/maps/documentation/javascript/examples/marker-labels
var marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i]["lat"], locations[i]["lng"]),
map: map,
title: "a title here"
});
眼下的注释是空白的,即使对于注释,标题被设定。我从来没有想过标题实际用于哪一种,因为标签是用于图标内的字符,标题对注释没有影响。
您可以用文本填充注释的标记属性是什么?
编辑: 谢谢Samuel Toh。
这里是工作的代码,我最终使用:
var locations;// use this as the array which holds the data
for (i = 0; i < locations.length; i++) {
about the locations you are adding to the map
var marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i]["lat"], locations[i]["lng"]),
map: map,
title: activities[i]["city"]
});
//extend the bounds to include each markers position
bounds.extend(marker.position);
google.maps.event.addListener(marker, "click", (function(marker, i) {
return function() {
infowindow.setContent(locations[i]["city"]);
infowindow.open(map, marker);
}
})(marker, i));
}
得到它!非常感谢你 – stackOverFlew
= o正试图为你构建一个jsFiddle例子,但既然你知道了......那么我会放弃这个想法:P懒得建立一个hee –
哈哈谢谢!我刚刚发布了我最终使用的代码。非常感谢! – stackOverFlew