我在使用fitBounds
地图方法的地图上遇到问题,它应该提供适当的缩放并将地图居中,并为其提供一个纬度数组。这是代码:
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script>
<div id="map_canvas">
<script type="text/javascript">
var map;
var bounds = new google.maps.LatLngBounds(null);
function initialize() {
var mapOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
<?php
foreach ($this->getProductCollection() as $_e):
$event = Mage::getModel('catalog/product')->load($_e->getId());
?>
var loc = new google.maps.LatLng("<?php echo $event->getEventLocationLatitude(); ?>","<?php echo $event->getEventLocationLongitude(); ?>");
bounds.extend(loc);
addMarker(loc, '<?php echo $event->getName(); ?>', "active");
bounds.extend(loc);
<?php endforeach; ?>
map.fitBounds(bounds);
map.panToBounds(bounds);
}
function addMarker(location, name, active) {
var marker = new google.maps.Marker({
position: location,
map: map,
title: name,
status: active
});
}
jQuery.noConflict();
jQuery(document).ready(function(){
initialize();
});
</script>
标记已正确放置在地图上,但我得到了可用的最大缩放:
有什么帮助吗?