我刚刚将我的代码从 v2 更新到 v3。一切正常,但功能map.fitBounds();
这是我的示例代码
var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': 'your address'}, >function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var newPoint = new google.maps.LatLng(results[0].geometry.location.lat(), >results[0].geometry.location.lng()); markerBounds.extend(newPoint); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else { alert('Geocode was not successful for the following reason: ' + status); } }); map.fitBounds(markerBounds);
}
我发现这段代码看起来不错,但 fitBounds() 在这里不起作用。下面的答案中提到了所需的更改。