我对 Leaflet.js 很陌生,我正在尝试弄清楚如何将具有相同选项和图层集的相同地图分配给不同的 HTML 容器,而不必每次都删除和添加一个新容器时间?
I'm pretty new to leaflet.js and I'm trying to figure out how to assign the same map with the same set of options and layers to a different HTML container instead of having to remove and add a new one every time?
我曾经处理 Open layers 2.13,我有 map.render(div);每次我想将地图设置为另一个 div 时的选项.有没有类似的解决方案?非常感谢!
I used to deal with Open layers 2.13 and I had map.render(div); option every time I wanted to set map to another div. Is there a solution similar to this? Many thanks!
可以,但是要复制图层
// add an OpenStreetMap tile layer
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// add the same OpenStreetMap tile layer to the second map
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map2);
http://jsfiddle.net/FranceImage/aj44r7v2/
这篇关于同一页面上的多个传单地图具有相同的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
检查一个多边形点是否在传单中的另一个内部Check if a polygon point is inside another in leaflet(检查一个多边形点是否在传单中的另一个内部)
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
触发点击传单标记Trigger click on leaflet marker(触发点击传单标记)
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
将外部geojson添加到传单层Add external geojson to leaflet layer(将外部geojson添加到传单层)
将 Leaflet 图层控件添加到侧边栏Adding Leaflet layer control to sidebar(将 Leaflet 图层控件添加到侧边栏)