Cannot read property '_latLngToNewLayerPoint' of null

1,067 阅读1分钟

使用leaflet在缩放时报错,解决办法,使用以下代码覆盖原本的方法(在任意文件引入改代码即可)

L.Popup.prototype._animateZoom = function (e) {
  if (!this._map) {
    return
  }
  var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),
    anchor = this._getAnchor()
  L.DomUtil.setPosition(this._container, pos.add(anchor))
}