* @function GeojsonLayer.prototype.add * @param {Object} layer - Mapbox layer 地图对象。 * @param {string} beforeId - Mapbox GL 地图对象。
(layer, beforeId)
| 27 | * @param {string} beforeId - Mapbox GL 地图对象。 |
| 28 | */ |
| 29 | add(layer, beforeId) { |
| 30 | const { id, source } = layer; |
| 31 | this.layerId = id; |
| 32 | if (this._existed()) { |
| 33 | return; |
| 34 | } |
| 35 | if (typeof source === 'object') { |
| 36 | const newData = this.eachData(cloneDeep(source.data)); |
| 37 | layer.source.data = newData; |
| 38 | } |
| 39 | |
| 40 | this.map.addLayer(layer, beforeId); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @function GeojsonLayer.prototype.remove |