初始化后查找传单地图对象 [英] Find Leaflet map object after initialisation

查看:94
本文介绍了初始化后查找传单地图对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用传单库来更改已经由另一个脚本初始化的地图上的某些内容. .这个其他脚本没有将地图对象存储在全局变量中,也没有存储在我可以通过脚本访问的任何其他位置.因此,当前页面上有一张地图,但是我没有地图对象.

I'm trying to change some things on a map that is already initialised by another script, using the Leaflet library. This other script did not store the map-object in a global variable, or in any other location I can access with my script. So currently there is a map on my page, but I don't have the map object.

我想做的是检索已经初始化的地图的对象,对其进行更改.例如,如果存在函数L.getMap('myID'),我想使用这种方法来检索链接到容器myID的地图对象.

What I'd like to do is to retrieve the object of an already-initialised map, to make changes to it. For example, if there'd exist a function L.getMap('myID') I'd like to use such a method to retrieve the map object linked to the container myID.

TL; DR:有没有一种方法可以使用容器的ID来获取已经初始化的传单地图的地图对象?

TL;DR: Is there a way to get a map object of an already-initialised leaflet map, using the id of the container?

推荐答案

您可以从由mediawiki扩展创建的全局数组中访问地图.

You can access the map from the global array created by the mediawiki extension.

Es:用于访问页面的第一张地图

Es: for accessing the first map of the page

window.maps.leafletList[0].map.getCenter()

这篇关于初始化后查找传单地图对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆