-1
我想添加單獨的信息窗口到多個地圖標記在手機應用程序沒有太大的成功。當我運行我的應用程序並單擊任何標記時,每次都打開它的infoWindow。不知道我出錯的地方。如何添加單獨的infoWindows到多個谷歌地圖標記
result.users.forEach(function(entry){
latLng = new google.maps.LatLng(entry.user_lat, entry.user_lon);
marker.push(new google.maps.Marker({map: map, position: latLng}));
circle.push(new google.maps.Circle({map: map, radius: entry.user_accuracy, strokeWeight:1, strokeOpacity:0.5, fillOpacity:0.2, fillColor: '#AA0000'}));
circle[circle.length-1].bindTo('center', marker[marker.length-1], 'position');
info.push(new google.maps.InfoWindow({content: '<b>Phone ID:</b> ' + entry.user_uuid + '<br /><b>Callsign:</b> ' + entry.user_callsign + '<br /><b>Time:</b> ' + entry.user_datestamp}));
google.maps.event.addListener(marker[marker.length-1], 'click', function() {info[info.length-1].open(map, marker[marker.length-1]);});
if (entry.user_uuid == device.uuid){
map.setCenter(latLng);
}
});
可能重複(http://stackoverflow.com/questions/3059044/google-maps-js-api -v3-simple-multiple-marker-example) – geocodezip
[Google Maps API v3向每個標記添加InfoWindow]的可能重複項(http://stackoverflow.com/questions/3158598/google-maps-api-v3-adding-一個-信息窗口對每個標誌物) – Jonathan