1
페이지에 4 개의지도를 배치하고 각 주소에 대한 마커를 추가하는 아래 코드가 있습니다. 그러나 마커를 중심으로 매핑해야합니다. Google지도 마커에 api 센터
하면 해당 맵의 마커의 중심을 만들 경우 완전히 확실하지
<script type="text/javascript">
var geocoder;
var map0,map1,map2,map3;
var markers = [];
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map0 = new google.maps.Map(document.getElementById("map_canvas1"), mapOptions);
addPostCode('@address1',map0);
map1 = new google.maps.Map(document.getElementById("map_canvas2"), mapOptions);
addPostCode('@address2',map1);
map2 = new google.maps.Map(document.getElementById("map_canvas3"), mapOptions);
addPostCode('@address3',map2);
map3 = new google.maps.Map(document.getElementById("map_canvas4"), mapOptions);
addPostCode('@address4',map3);
}
function addPostCode(address,map) {
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
center: results[0].geometry.location,
name: address
});
markers.push(marker);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
.
이 줄은 마커에 대해 의미가 없습니다. 'center : results [0] .geometry.location,'- 마커는'중심 ' – duncan