地址标记已放大。如何让单个标记的缩放更远?如果有人可以提供帮助那就太棒了!这是我的JavaScript。谢谢你的帮助
$('#map_here').prepend('<div id="map"></div>');
$(".static_map").remove();
var map;
var bounds;
var geocoder;
var center;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 5
};
map = new google.maps.Map(document.getElementById("map"),
mapOptions);
geocoder = new google.maps.Geocoder();
bounds = new google.maps.LatLngBounds();
}
function addMarkerToMap(location){
var marker = new google.maps.Marker({map: map, position: location});
bounds.extend(location);
map.fitBounds(bounds);
}
initialize();
$("address").each(function(){
var $address = $(this);
geocoder.geocode({address: $address.text()}, function(results, status){
if(status == google.maps.GeocoderStatus.OK) addMarkerToMap(results[0].geometry.location);
});
});
google.maps.event.addDomListener(map, "idle", function(){
center = map.getCenter();
});
$(window).resize(function(){
map.setCenter(center);
});
答案 0 :(得分:0)
找出有效的方法。我在map.fitBounds(bounds)之前添加了这段代码;它起作用了:
google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
if (this.getZoom() > 15) {
this.setZoom(15);
}
});