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

L.GridLayer.include({
  getEvents() {
    const events = gridLayerProto.getEvents.call(this)
    if (this._map._rotate && !this.options.updateWhenIdle) {
      if (!this._onRotate) {
        this._onRotate = L.Util.throttle(
          this._onMoveEnd,
          this.options.updateInterval,
          this
        )
      }
      events.rotate = this._onRotate
    }
    return events
  },

  _getTiledPixelBounds(center) {
    if (!this._map._rotate) {
      return gridLayerProto._getTiledPixelBounds.call(this, center)
    }

    const map = this._map
    const mapZoom = map._animatingZoom
      ? Math.max(map._animateToZoom, map.getZoom())
      : map.getZoom()
    const scale = map.getZoomScale(mapZoom, this._tileZoom)
    const pixelCenter = map.project(center, this._tileZoom).floor()
    const size = map.getSize()
    const halfSize = new L.Bounds([
      map.containerPointToLayerPoint([0, 0]).floor(),
      map.containerPointToLayerPoint([size.x, 0]).floor(),
      map.containerPointToLayerPoint([0, size.y]).floor(),
      map.containerPointToLayerPoint([size.x, size.y]).floor()
    ])
      .getSize()
      .divideBy(scale * 2)

    return new L.Bounds(
      pixelCenter.subtract(halfSize),
      pixelCenter.add(halfSize)
    )
  }
})
构造函数
成员变量
方法
事件