* @function GraphicLayer.prototype.getMapState * @description 获取当前地图状态。 * @returns {Object} 地图状态,包含地图状态信息。
()
| 210 | * @returns {Object} 地图状态,包含地图状态信息。 |
| 211 | */ |
| 212 | getMapState() { |
| 213 | let state = {}; |
| 214 | let center = this.map.getCenter(); |
| 215 | let longitude = center.lng; |
| 216 | let latitude = center.lat; |
| 217 | let zoom = this.map.getZoom(); |
| 218 | let maxZoom = this.map.getMaxZoom(); |
| 219 | let pitch = this.map.getPitch(); |
| 220 | let bearing = this.map.getBearing(); |
| 221 | |
| 222 | let mapViewport = { |
| 223 | longitude: longitude, |
| 224 | latitude: latitude, |
| 225 | zoom: zoom, |
| 226 | maxZoom: maxZoom, |
| 227 | pitch: pitch, |
| 228 | bearing: bearing |
| 229 | }; |
| 230 | for (let key in mapViewport) { |
| 231 | state[key] = mapViewport[key]; |
| 232 | } |
| 233 | //当使用扩展的mapboxgl代码时有效 |
| 234 | if (this.map.getCRS && this.map.getCRS() !== mapboxgl.CRS.EPSG3857) { |
| 235 | state.coordinateSystem = this.coordinateSystem; |
| 236 | state.isGeographicCoordinateSystem = this.isGeographicCoordinateSystem; |
| 237 | } |
| 238 | return state; |
| 239 | } |
| 240 | } |
no test coverage detected