【发布时间】:2015-12-02 13:54:28
【问题描述】:
我已经实现了谷歌标记,我想在标记内显示一个名称。我试图更改标签:如下代码,但它只显示第一个字符..有人可以告诉我如何解决这个问题吗?
这是来自谷歌的标记代码
function initialize() {
var bangalore = { lat: 12.97, lng: 77.59 };
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: bangalore
});
// This event listener calls addMarker() when the map is clicked.
google.maps.event.addListener(map, 'click', function(event) {
addMarker(event.latLng, map);
});
// Add a marker at the center of the map.
addMarker(bangalore, map);
}
// Adds a marker to the map.
function addMarker(location, map) {
// Add the marker at the clicked location, and add the next-available label
// from the array of alphabetical characters.
var marker = new google.maps.Marker({
position: location,
label: "lets showthis",
map: map
});
}
google.maps.event.addDomListener(window, 'load', initialize);
【问题讨论】:
标签: javascript google-maps google-maps-api-3