我的部分代码看起来像这样,我可以使用
map.setCenter(myLatlng);
但是在那之后我试图缩放地图
marker_id = id;
marker_id = new google.maps.Marker();
marker_id.setIcon(image);
myLatlng = new google.maps.LatLng(loctionupdateobj[id].lat, loctionupdateobj[id].lang);
marker_id.setPosition(myLatlng);
marker_id.setMap(map);
map.setCenter(myLatlng);
alert(map.getZoom());
map.setZoom(10);
alert("game again " + map.getZoom())
你可以看到
alert("game again " + map.getZoom())
在代码中,它给了我类似
game again 10
的警报,但是缩放级别永远不会达到10
。但是第一个警报是
4
(我在初始化期间设置的)。由于我无法执行
setZoom
,因此每次添加新标记时都在创建一个新的地图实例。 最佳答案
终于找到了 !!!
以前为我的项目编码的程序员写了一行
google.maps.event.clearListeners(map);