[英]Migration from google maps V2 to Version 3
我正在从Google Maps V2到V3的迁移项目中工作,无法进行以下工作。
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=myApiKey&sensor=false">
</script>
<script>
function initialize()
{
var map=new google.maps.Map(document.getElementById("googleMap"));
map.setCenter(new google.maps.LatLng(51.508742,-0.120850),5);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
实际上,我不想在新的google.maps.Map
函数中使用options参数。 我想使用map.center函数将地图居中。
这是错误的:
map.setCenter(new google.maps.LatLng(51.508742,-0.120850),5);
setCenter仅采用一个参数LatLng对象。 尝试这个:
map.setCenter(new google.maps.LatLng(51.508742,-0.120850));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.