克隆谷歌地图实例 [英] clone google map instance
问题描述
我在一个页面上有一张地图,其中显示了几个标记和infowindows的地方。
现在我想放置一个全屏按钮并将地图加载到jquery-ui对话框中,但我遇到了一些问题。
一个方法来复制我创建的谷歌地图实例在一个div,到另一个div?
或者任何其他解决方法,如更改与地图关联的div。 ..科幻作品
我认为Google地图本身并不支持这种操作。
尽管移动地图似乎很简单。该地图有一个方法getDiv,它返回包含地图的节点。使用jQuery,您可以操作DOM:
var mapNode = that.map.getDiv();
$('#destinationDiv')。append(mapNode);
它只是将地图div移动到destinationDiv中。我在Chrome和Firefox中测试过它,它运行良好,但我不确定它是否能够在所有主要浏览器中正常工作(如果地图功能未被破坏)。
但是我没有成功复制地图。使用jQuery的克隆方法会生成地图的破碎副本。如果您需要复制它,我想唯一的方法可能是创建全新的地图并从头创建所有对象。
I have a map on a page which displays several places with markers and infowindows. Now I'd like to put a fullscreen button and load the map into a jquery-ui dialog, but I've got some problems.
Is there a way to copy the google map instance I've created in one div, into the other div?
Or any other workaround, like changing the div associated with the map... science-fiction??
I don't think Google Maps themselves support such manipulation.
Although it seems that moving the map is quite simple. The map has a method getDiv which returns Node containing the map. Using jQuery you can then manipulate the DOM:
var mapNode = that.map.getDiv();
$('#destinationDiv').append(mapNode);
It simply moves the map div into the destinationDiv. I tested it in Chrome and Firefox and it worked well, but I'm not really sure if it works properly (if the map's functionality isn't broken) in all main browsers.
But I wasn't successful in copying the map. Utilizing jQuery's clone method produces broken copy of the map. If you need to copy it, I guess the only way might be to create completely new map and create all the objects from scratch.
这篇关于克隆谷歌地图实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!