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

Function getCenter

src/leaflet/mapping/initMap.js:214–223  ·  view source on GitHub ↗

* @private * @function getCenter * @description 获取center。 * @param {CRS} crs - crs。 * @param {Object} mapJSONObj - 地图 JSON 对象。 * @param {Object} mapJSONObj.center - 地图参数。 * @param {Object} mapJSONObj.bounds - 地图最大缩放级别。 * @returns {Object} center。

(crs, { center, bounds })

Source from the content-addressed store, hash-verified

212 * @returns {Object} center。
213 */
214function getCenter(crs, { center, bounds }) {
215 const code = typeof crs === 'string' ? crs : crs.code;
216 if (typeof center.x !== 'number' && typeof center.y !== 'number') {
217 center = { lat: (bounds.bottom + bounds.top) / 2, lng: (bounds.left + bounds.right) / 2 };
218 }
219 if (code === 'EPSG:4326') {
220 return { lat: center.y, lng: center.x };
221 }
222 return crs.unproject(L.point(center.x, center.y));
223}
224function getLatLngBounds(bounds, crs) {
225 const code = typeof crs === 'string' ? crs : crs.code;
226 if (code === 'EPSG:4326') {

Callers 3

initMapFunction · 0.70
createViewMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected