@ciniki/iclient-maplibregl
Version:
@supermapgis/iclient-maplibregl 是一套基于 Maplibre GL 的云 GIS 网络客户端开发平台, 支持访问 SuperMap iServer / iEdge / iPortal / iManager / Online 的地图、服务和资源,为用户提供了完整专业的 GIS 能力, 同时提供了优秀的可视化功能。
33 lines (27 loc) • 787 B
JavaScript
import maplibregl from 'maplibre-gl';
export class CRSManager {
constructor(proj4) {
this.proj4 = proj4;
this.builtInEPSG = ['EPSG:3857', 'EPSG:4326'];
}
isSameProjection(map, epsgCode) {
return map.getCRS().epsgCode === epsgCode;
}
getProj4() {
return this.proj4 || maplibregl.proj4;
}
getCRS(epsgCode) {
return maplibregl.CRS.get(epsgCode);
}
registerCRS({ name, wkt, extent, unit }, autoRegister = true) {
let crs = maplibregl.CRS.get(name);
if (!crs) {
crs = new maplibregl.CRS(name, wkt, extent, unit || extent[2] > 180 ? 'meter' : 'degree');
autoRegister && maplibregl.CRS.set(crs);
}
if (this.proj4 && !this.builtInEPSG.includes(name)) {
this.proj4.defs(name, crs.getWKT());
}
return crs;
}
}