* @function GeojsonSource.prototype.add * @description 添加数据源。 * @param {string} id - 数据源 Id。 * @param {Object} source
(id, source)
| 28 | * @param {Object} source |
| 29 | */ |
| 30 | add(id, source) { |
| 31 | if (this.map.getSource(id)) { |
| 32 | return; |
| 33 | } |
| 34 | const newData = cloneDeep(source.data); |
| 35 | featureEach(newData, (currentFeature) => { |
| 36 | coordEach(currentFeature, (curCoords) => { |
| 37 | let transCurCoords = proj4('EPSG:4326', 'EPSG:3857', curCoords); |
| 38 | let transCoords = this.coordTransfer.toVideoCoordinate(transCurCoords); |
| 39 | curCoords.length = 0; |
| 40 | curCoords.push( |
| 41 | ...transformCoord({ |
| 42 | videoPoint: transCoords.data64F, |
| 43 | videoWidth: this.videoWidth, |
| 44 | videoHeight: this.videoHeight, |
| 45 | originCoordsRightBottom: this.originCoordsRightBottom, |
| 46 | originCoordsLeftTop: this.originCoordsLeftTop |
| 47 | }) |
| 48 | ); |
| 49 | }); |
| 50 | }); |
| 51 | |
| 52 | source.data = newData; |
| 53 | |
| 54 | this.map.addSource(id, source); |
| 55 | } |
| 56 | /** |
| 57 | * @function GeojsonSource.prototype.remove |
| 58 | * @description 移除数据源。 |
no test coverage detected