类名 util/extend/layer/DivOverlay.js
import * as L from '@mapgis/leaflet'
// @link https://github.com/Raruto/leaflet-rotate
/**
 * L.DivOverlay
 */
const divOverlayProto = L.extend({}, L.DivOverlay.prototype)

L.DivOverlay.include({
  getEvents() {
    return L.extend(divOverlayProto.getEvents.call(this), {
      rotate: this._updatePosition
    })
  },

  _updatePosition() {
    if (!this._map) {
      return
    }

    let pos = this._map.latLngToLayerPoint(this._latlng)
    let offset = L.point(this.options.offset)
    const anchor = this._getAnchor()

    if (this._zoomAnimated) {
      // TODO: use divOverlayProto._updatePosition
      if (this._map._rotate) {
        pos = this._map.rotatedPointToMapPanePoint(pos)
      }
      L.DomUtil.setPosition(this._container, pos.add(anchor))
    } else {
      offset = offset.add(pos).add(anchor)
    }

    const bottom = (this._containerBottom = -offset.y)
    const left = (this._containerLeft =
      -Math.round(this._containerWidth / 2) + offset.x)

    // bottom position the popup in case the height of the popup changes (images loading etc)
    this._container.style.bottom = `${bottom}px`
    this._container.style.left = `${left}px`
  }
})
构造函数
成员变量
方法
事件