我正在使用 biostall 提供的 Google Maps CI 库。我想要平移到已单击的标记,以便 map 以该标记为中心。
我已经尝试过这个JS,但似乎标记对象没有 getLatLng() 方法。
function open_marker(id){
google.maps.event.trigger(markers[id],'click'); // this works fine, opens the correct marker
map.panTo(markers[id].getLatLng());
return;
}
收到错误:
Uncaught TypeError: Object #V> has no method 'getLatLng'
我需要获取一个可以 getLatLng() 的标记对象。
当我alert(markers[id])
时,它说对象,所以我假设它存在。
最佳答案
getLatLng()
位于 API v2
在 API v3 中使用 getPosition()
代替
所有选项和方法请参见 Google Maps Javascript API V3 Reference
关于javascript - CodeIgniter Gmaps 获取标记对象经纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10755254/