$('#map_canvas').gmap().bind('init', function(ev, map) {
if (myPosition) {
$('#map_canvas').gmap({ 'center' : myPosition });
$('#map_canvas').gmap('addMarker', { 'position': myPosition, 'bounds': true, 'icon' : '../../css/images/current_location.png'}).click( function () {
$('#map_canvas').gmap('openInfoWindow', { 'content': 'You are here!' }, this);
});
$('#map_canvas').gmap('option', 'zoom', 20);
} else {
$('#map_canvas').gmap('option', 'zoom', 8);
}
$.each(markers, function(i, marker) {
$('#map_canvas').gmap('addMarker', {
'position': new google.maps.LatLng(marker.lat, marker.lng),
'bounds': true
}).click(function() {
$('#map_canvas').gmap('openInfoWindow', { 'content': marker.name }, this);
});
});
});
我想居中并缩放到特定位置。这段代码的结果:http: //postimage.org