2
모든 마커를 중앙에두고지도를 자동 확대하여 내지도에 모두 맞게하는 방법을 알아야합니다. 나는 그것을 해결하기 위해 며칠간 머리를 부러 뜨리고있다. 제발 도와주세요.Google지도 V3 가운데 다중 마커 및 자동 확대/축소 문제
내 코드
<script type="text/javascript">
var map;
var address = new Array();
//we can also create following array with a for loop
address[0] = '798 9th Ave, New York, NY';
address[1] = '42 E 29th St, New York, NY';
address[2] = '56 W 25th St, New York, NY';
address[3] = '26 W 21th St, New York, NY';
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
for (var i=0; i<=address.length; i++) {
geocoder.geocode({'address': address[i]}, function(results, status) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({map: map, position: results[0].geometry.location});
});
}
}
</script>
당신은 그것을 잔인한 그리고 그것은 필요 아니에요, 루프에서 map.setCenter을 제거 할 수 있습니다. – s3m3n