2010-03-04 6 views
2

Google지도 아이콘을 사용합니다. 정보창에 표시 할 정보 배열이 있습니다. 나는 마커 정보 창

markers = xml.documentElement.getElementsByTagName("marker"); 

for (i = 0; i < markers.length; i++) 
{ 

    info = markers[i].getAttribute("info"); 
    GEvent.addListener(markers[i], "click", function(info) { 
      this.openInfoWindowHtml(info);      
    }); 
} 

openInfoWindowHtml(info)

마커 각각의 모든 표시해야하며,이 같은 노력했다. 정보 창을 표시해야합니다.

감사 v.srinath

답변

0

당신은 marker

고정 코드는 스크립트 아래

markers = xml.documentElement.getElementsByTagName("marker"); 

for (i = 0; i < markers.length; i++) 
{ 

    info = markers[i].getAttribute("info"); 
    GEvent.addListener(markers[i], "click", function() { 
      markers[i].openInfoWindowHtml(info);      
    }); 
} 
+0

맞춤법 오류로 인해 유감스럽게 생각합니다. 참으로 GEvent.addListener (마커 [i], ..)입니다. 이제 편집했습니다. 여전히 작동하지 않습니다. 감사합니다. v.srinath –

+0

답을 업데이트하고 시도해보십시오. – antyrat

+0

XML 파일 예제를 표시 할 수 있습니까? 마커를 만드는 곳이 보이지 않습니다. 다음과 같이되어야합니다 : var marker = new GMarker (point); 여기서 var point = new GLatLng (lat, lng); – antyrat

2

확인은 배열을 거기없는이 줄 GEvent.addListener(marker[i], "click", function(info) {에서 코드에서 오류가 있는지 확인 API가있는 Google지도를 추가하려면

 
    // When the window has finished loading create our google map below 
    google.maps.event.addDomListener(window, 'load', init); 
    function init() 
    { 
    // Basic options for a simple Google Map 
    // For more options see: https://developers.google.com/maps/documentation  //javascript/reference#MapOptions 
    var mapOptions = { 
    // How zoomed in you want the map to start at (always required) 
    zoom: 4,

// The latitude and longitude to center the map (always required) center: new google.maps.LatLng(25.985448,52.7994103), // Main map location navigationControl: false, mapTypeControl: false, scaleControl: false, draggable: false, scrollwheel: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, position: google.maps.ControlPosition.BOTTOM_LEFT }, // How you would like to style the map. // This is where you would paste any style found on Snazzy Maps. styles: [] }; // Get the HTML DOM element that will contain your map // We are using a div with id="map" seen below in the <body> var mapElement = document.getElementById('googlemap'); // Create the Google Map using our element and options defined above var map = new google.maps.Map(mapElement, mapOptions); // address content Kuwait var location1 = '<div id="content">'+ '<div id="siteNotice">'+ '</div>'+ '<h1 id="firstHeading" class="firstHeading">Location1 name</h1>'+ '<div id="bodyContent">'+ '<p> Location 1 content' + '</p>'+ '</div>'+ '</div>'; var infolocation1 = new google.maps.InfoWindow({ content: location1 }); // Location Kuwait var marker1 = new google.maps.Marker({ position: new google.maps.LatLng(29.363765,47.966278), map: map, title: '' }); marker1.addListener('click', function() { infolocation1.open(map, marker1); }); // address content Kuwait var location2 = '<div id="content">'+ '<div id="siteNotice">'+ '</div>'+ '<h1 id="firstHeading" class="firstHeading"> Location2 name</h1>'+ '<div id="bodyContent">'+ '<p> Location 2 content' + '</p>'+ '</div>'+ '</div>'; var infolocation2 = new google.maps.InfoWindow({ content: location2 }); // Location Kuwait var marker2 = new google.maps.Marker({ position: new google.maps.LatLng(29.363765,47.966278), map: map, title: '' }); marker2.addListener('click', function() { infolocation2.open(map, marker2); }); } </pre>
관련 문제