【发布时间】:2012-07-01 03:51:34
【问题描述】:
我有几个要检索的标记,并希望将地图居中。 是的,我已经阅读了所有其他答案,但它似乎对我不起作用: Google Map API v3 — set bounds and center
JS:
geocoder.geocode( {'address': loc}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var markerBounds = new google.maps.LatLngBounds();
var coordinate = results[0].geometry.location;
var icon = new google.maps.MarkerImage("images/icon-"+type+".png", new google.maps.Size(37, 44));
//create the marker
var marker = new google.maps.Marker({
map: map,
position: coordinate,
visible: true,
id: type,
shadow: shadow,
icon: icon
});
markerBounds.extend(coordinate);
map.fitBounds(markerBounds);
}
}
【问题讨论】:
标签: javascript google-maps google-maps-api-3 bounds