MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / getMapState

Method getMapState

src/mapboxgl/overlay/GraphicLayer.js:212–239  ·  view source on GitHub ↗

* @function GraphicLayer.prototype.getMapState * @description 获取当前地图状态。 * @returns {Object} 地图状态,包含地图状态信息。

()

Source from the content-addressed store, hash-verified

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 }

Callers 1

getStateMethod · 0.45

Calls 3

getZoomMethod · 0.45
getMaxZoomMethod · 0.45
getCRSMethod · 0.45

Tested by

no test coverage detected