MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / initMap

Function initMap

src/maplibregl/mapping/InitMap.js:36–67  ·  view source on GitHub ↗
(url, options = {})

Source from the content-addressed store, hash-verified

34 * ```
35 * */
36export function initMap(url, options = {}) {
37 const initMapService = new InitMapServiceBase(MapService, url, options);
38 return initMapService.getMapInfo(async (res, resolve, reject) => {
39 try {
40 if (res.type === 'processCompleted') {
41 const {
42 dynamicProjection,
43 prjCoordSys: { epsgCode, type }
44 } = res.result;
45 if (isPlaneProjection(type)) {
46 reject(new Error('maplibre-gl cannot support plane coordinate system.'));
47 return;
48 }
49 if (epsgCode !== 3857 && !dynamicProjection && !maplibregl.CRS) {
50 reject(
51 new Error(
52 `The EPSG code ${epsgCode} needs to include maplibre-gl-enhance.js. Refer to the example: https://iclient.supermap.io/examples/maplibregl/editor.html#mvtVectorTile_2362`
53 )
54 );
55 return;
56 }
57 const mapOptions = await createMapOptions(url, res.result, { ...options, initMapService });
58 const map = new maplibregl.Map(mapOptions);
59 resolve({ map });
60 return;
61 }
62 reject(new Error('Fetch mapService is failed.'));
63 } catch (error) {
64 reject(error);
65 }
66 });
67}
68
69/**
70 * @private

Callers

nothing calls this directly

Calls 3

getMapInfoMethod · 0.95
isPlaneProjectionFunction · 0.90
createMapOptionsFunction · 0.70

Tested by

no test coverage detected