[英]Get Map Object in Javascript after using CodeIgniter Google Maps API
I'm using the codeigniter library for the google maps api. 我正在为Google Maps API使用codeigniter库。 I load the map using the library located on the CI Wiki: http://www.phpinsider.com/php/code/GoogleMapAPI/
我使用位于CI Wiki上的库加载地图: http : //www.phpinsider.com/php/code/GoogleMapAPI/
I want to then use javascript on the map object after loading the page. 我想在加载页面后在地图对象上使用javascript。 How can I get the map object in javascript?
如何在JavaScript中获取地图对象? Can I use GMap2 on the same div?
我可以在同一个div上使用GMap2吗? Won't that recreate the map?
那会不会重新创建地图?
The reason I want to do this is to bind an event to the map. 我要执行此操作的原因是将事件绑定到地图。
Thanks! 谢谢!
Hope this works: 希望这行得通:
var myMap;
function getMap()
{
if(myMap == null)
myMap = new GMap2(document.getElementById("map"));
return myMap;
}
and then refer to this function to get reference to the GMap2 object. 然后引用此函数以获取对GMap2对象的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.