* @function DeckglLayer.prototype.onAdd * @param {mapboxgl.Map} map - MapBoxGL Map 对象。 * @returns {DeckglLayer}
(map)
| 87 | * @returns {DeckglLayer} |
| 88 | */ |
| 89 | onAdd(map) { |
| 90 | this.map = map; |
| 91 | if (this.canvas) { |
| 92 | this.mapContainer = this.map.getCanvasContainer(); |
| 93 | return this; |
| 94 | } |
| 95 | //当使用扩展的mapboxgl代码时有效 |
| 96 | if (this._isEPSG3857()) { |
| 97 | this.coordinateSystem = 3; |
| 98 | this.isGeographicCoordinateSystem = true; |
| 99 | } else { |
| 100 | this.coordinateSystem = 1; |
| 101 | this.isGeographicCoordinateSystem = false; |
| 102 | } |
| 103 | //创建图层容器 |
| 104 | this._initContainer(this.map.getCanvasContainer(), this.map.getCanvas()); |
| 105 | |
| 106 | //创建 deckgl 图层 |
| 107 | this._createLayerByLayerTypeID(); |
| 108 | |
| 109 | var mapState = this._getState(); |
| 110 | let deckOptions = {}; |
| 111 | for (let key in mapState) { |
| 112 | deckOptions[key] = mapState[key]; |
| 113 | } |
| 114 | deckOptions.layers = [this.layer]; |
| 115 | deckOptions.canvas = this.canvas; |
| 116 | this.deckGL = new window.DeckGL.experimental.DeckGLJS(deckOptions); |
| 117 | this._draw(); |
| 118 | return this; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @function DeckglLayer.prototype.onRemove |
nothing calls this directly
no test coverage detected