2014-11-04 5 views
0

텍스트로 클릭하여 infowindow를 열려고하지만 클러스터가있을 때 아무 것도 호출 할 수 없습니다.Google지도 API3 외부 링크에서 클러스터 된 마커의 infowindow 열기

이미지 : 내가 정보창 열 수 있습니다 클러스터없이 http://s4.postimg.org/khw51khot/aaa.png

function open_window(io) { // my function to open info window from external link 
 
    //alert(io); 
 
    infowindow.setContent(locations[io][0]); 
 
    infowindow.open(map, marker); 
 
    (marker, io); 
 
} 
 

 
function initialize() { 
 

 
    var infowindow = new google.maps.InfoWindow(); 
 

 

 
    var center = new google.maps.LatLng(37.4419, 110.1419); 
 

 
    var map = new google.maps.Map(document.getElementById('map'), { 
 
    zoom: 3, 
 
    center: center, 
 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
 
    }); 
 

 
    var markers = []; 
 
    for (var i = 0; i < locations.length; i++) { 
 

 
    var latLng = new google.maps.LatLng(locations[i][2], locations[i][1]); 
 
    var marker = new google.maps.Marker({ 
 
     position: latLng 
 

 
    }); 
 

 
    markers.push(marker); 
 
    google.maps.event.addListener(marker, 'click', (function(marker, i) { 
 
     return function() { 
 
     infowindow.setContent(locations[i][0]); 
 
     infowindow.open(map, marker); 
 
     } 
 
    })(marker, i)); 
 
    } 
 

 
    var markerCluster = new MarkerClusterer(map, markers); 
 

 
} 
 

 
google.maps.event.addDomListener(window, 'load', initialize); < /script> 
 
    </head > 
 
<body> 
 
    <h3> < /h3> 
 
    <table border="1"> 
 
\t <tr><td> 
 
    <div id="map-container"><div id="map"></div > < /div> 
 
    </td > 
 
    < td width = "400px" > 
 
    < div style = "height:600px;width:400px;border:1px solid #ccc;font:12px/26px Georgia, Garamond, Serif;overflow:auto;" > 
 
    < script type = "text/javascript" > // script to generate the links to open window can pass number already tried alert function 
 
    for (io = 0; io < locations.length; io++) { 
 
    document.write(" <p id=" + io + " onclick='open_window(this.id)'>"); 
 
    document.write(locations[io][3]); 
 
    document.write(io); 
 
    document.write("</p>"); 
 
    } < /script> 
 
\t </div > 
 
    < /td> 
 
\t </tr > 
 
    < /table>

, 내가 뭘하려고하고하는 것은 열린 정보창 및 그 제조 업체에지도에 초점을 것입니다.

+0

[this] (http://www.geocodezip.com/v3_MW_example_map3_clustered.html)와 유사합니까? – geocodezip

+0

정보창을 여는 방법을 찾았습니다. "var marker []"를 초기화 함수에서 꺼 냈습니다.하지만 창과 장소 및 이벤트 트리거는 있지만 정보창은 제작자에게 확대되지 않습니다. – user2991150

답변

0

는 문제점 1) 위 VAR 마커 [] 아웃) 2- 초기화 이벤트 트리거 기능과 트리거 마커 클릭 이벤트 3-) 마커 위치 map.setCenter으로 설정 위치를 만들 해결 (marker.getPosition()) ; 9 줌 MAXZOOM에 4-) 제한 클러스터 : 외장 링크에서 호출하고이 가정되는 위치에 배치 9

정보창가되게합니다 :) 와 나는 3 커피 + 1 콜라 + 1 스니커즈 초콜릿 바로했다.

+0

할 수 있으면 재미있을 것입니다. 코드를 공유하십시오. 나는 더 많거나 적은 것을 찾고 있습니다. – BeoWulf