사이드 바를 추가하려고합니다. 나는 name
변수를 데이터베이스에서 가져온 사이드 바에있는 링크에 사용하고 있는데 배열로 사용할 수 있습니다. 두 번 반복 할 수 없으므로 Google 데이터베이스에 QUERY_LIMIT
을 넣습니다.사이드 바를 마커에 연결하는 방법
아무에게도이 기능을 사용하는 방법에 대한 논리를 제공 할 수 있습니까? 여기
내 스크립트입니다<script type="text/javascript">
var markers = [];
var side_html = "";
var icon1 = "prop.png";
var icon2 = "office.png";
var locations = <?php echo $add_js ?>;
var name = <?php echo $name_js ?>
//function that will be used to handle clicks on the links in the sidebar
function myclick(num) {
google.maps.event.trigger(locations[num], "click");
}
function geocodeAddress(i)
{
geocoder.geocode({'address' : locations[i]},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
createMarker(results[0].geometry.location, i);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
function createMarker(latlng,i) {
var marker = new google.maps.Marker({
map : map,
icon : icon1,
position : latlng
});
var infowindow = new google.maps.InfoWindow({
size: new google.maps.Size(150,50),
disableAutoPan: true
});
google.maps.event.addListener(marker, 'mouseover', function() {
marker.setIcon(icon2);
infowindow.setContent(locations[i]);
infowindow.open(map, marker);
});
google.maps.event.addListener(marker, 'mouseout', function() {
marker.setIcon(icon1);
infowindow.setContent(locations[i]);
infowindow.close(map, marker);
});
return marker;
}
var map = new google.maps.Map(document.getElementById('map'), {
zoom : 10,
center : new google.maps.LatLng(28.6139, 77.2089),
mapTypeId : google.maps.MapTypeId.ROADMAP
});
//var infowindow = new google.maps.InfoWindow({size: new google.maps.Size(150,50)});
var geocoder = new google.maps.Geocoder();
for (var i = 0 ; i < locations.length; i++) {
geocodeAddress(i);
// link to the sidebar HTML that will open the info window for the record being processed
side_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br />';
document.getElementById("side_bar").innerHTML = side_html;
}//end of for loop
</script>
내가 출력에 적절한 마커를 얻고있다,하지만 난 이름 배열마다 전체 무엇입니까 및 링크 이벤트를 클릭하여도 응답하지 않는 사이드 바 링크로 . "이름이"배열 인 경우
는 당신이 DB에서 얻을 데이터의 예를 들어 주실 수 있습니까? 그것은 나에게 사이드 바 링크의 이름을 모두 배열을주고있다 –
'VAR 이름'배열 'VAR 위치'[ "노 소재지", "Dwarka 소재지", "구르 가온 Subcity" "자낙 지역"] 예를 들어 이름이 예를 들어 주소가 있습니다 [Janak Puri, New Delhi, India], "Sector 63, Noida", "Dwarka, New Delhi, India", "Gurgaon, Haryana, India"] 이름 필드를 사이드 바에 연결하고 싶습니다. 마커의 위치. – analyticalpicasso