首页 > 解决方案 > 如何获取地图的当前位置?(传单.js)

问题描述

我正在使用 Leaflet.js 和用户交互(发生在地图 div 之外),我想获取当前位置(纬度、经度、缩放)。

我可以找到缩放,但字段 _lastCenter 并没有让我得到实际位置,而是从地图初始化中获取坐标。

如何获取当前坐标?

this.getZoom = function () { return map._zoom }
this.getLat = function () { return map._lastCenter.lat }
this.getLon = function () { return map._lastCenter.lng  }

标签: jquerydictionaryleaflet

解决方案


推荐阅读