여러 마커 (> 1000)로 내 페이지에 Google지도를 넣으려고하고 있으며 각각 고유 한 정보 창이 있습니다. 배열을 통해 마커를 추가하고 마커가 잘 보이지만 모든 정보 창에는 똑같은 내용이 있습니다. 나는 손실에있어 크게 귀하의 정보를 주셔서 감사합니다. 그것은 desc
처럼 보이는Google지도 여러 정보 창이있는 여러 마커
<script>
var map;
var markersArray = [];
var infowindow = new google.maps.InfoWindow({
content: ''
});
function initialize() {
bounds = new google.maps.LatLngBounds();
usa = new google.maps.LatLng(37.09024, -95.712891);
var myOptions = {
zoom: 4,
center: usa,
mapTypeId: google.maps.MapTypeId.ROADMAP,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
plotMarkers();
}
// here is where the array content is contained
var webApps = [<%=strArray%>];
function plotMarkers(){
var i;
for(i = 0; i < webApps.length; i++){
codeAddresses(webApps[i]);
}
}
function codeAddresses(address){
// other variables
lat = address[3];
lng = address[4];
desc = address[0]
myLatlng = new google.maps.LatLng(lat,lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(desc);
infowindow.open(map, this);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map_canvas" style="width: 100%; height: 600px;"></div>
[Google Maps JS API v3 - 간단한 다중 마커 예] 중복 가능 (http://stackoverflow.com/questions/3059044/google-maps-js-api-v3-simple-multiple-marker-example) – geocodezip