* @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 })
| 212 | * @returns {Object} center。 |
| 213 | */ |
| 214 | function 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 | } |
| 224 | function getLatLngBounds(bounds, crs) { |
| 225 | const code = typeof crs === 'string' ? crs : crs.code; |
| 226 | if (code === 'EPSG:4326') { |
no outgoing calls
no test coverage detected