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

Method initializeMap

src/common/mapping/MapStyle.js:17–60  ·  view source on GitHub ↗
(_, map)

Source from the content-addressed store, hash-verified

15 }
16
17 initializeMap(_, map) {
18 this._baseProjection = this._registerMapCRS(this.mapOptions);
19 if (map) {
20 if (!crsManager.isSameProjection(map, this._baseProjection)) {
21 this.fire('projectionnotmatch');
22 return;
23 }
24 this._appendLayers = true;
25 this.map = map;
26 this._addLayersToMap();
27 return;
28 }
29 this.mapOptions.container = this.options.target;
30 if (!this.mapOptions.transformRequest) {
31 this.mapOptions.transformRequest = (url, resourceType) => {
32 let proxy = '';
33 if (typeof this.options.proxy === 'string') {
34 let proxyType = 'data';
35 if (resourceType === 'Tile') {
36 proxyType = 'image';
37 }
38 proxy = this.webMapService.handleProxy(proxyType);
39 }
40 return {
41 url: proxy ? `${proxy}${encodeURIComponent(url)}` : url,
42 credentials: this.webMapService.handleWithCredentials(proxy, url, false)
43 ? 'include'
44 : undefined,
45 ...(this.options.tileTransformRequest && this.options.tileTransformRequest(url))
46 };
47 };
48 }
49 this.mapOptions.center = this.mapOptions.center || [0, 0];
50 this.mapOptions.zoom = this.mapOptions.zoom || 0;
51 let fadeDuration = 0;
52 if (Object.prototype.hasOwnProperty.call(this.mapOptions, 'fadeDuration')) {
53 fadeDuration = this.mapOptions.fadeDuration;
54 }
55 this.map = new MapManager({ ...this.mapOptions, fadeDuration, crs: this._baseProjection });
56 this.fire('mapinitialized', { map: this.map });
57 this.map.on('load', () => {
58 this._sendMapToUser();
59 });
60 }
61
62 clean(removeMap = true) {
63 if (this.map) {

Callers

nothing calls this directly

Calls 8

_registerMapCRSMethod · 0.95
_addLayersToMapMethod · 0.95
_sendMapToUserMethod · 0.95
handleProxyMethod · 0.80
handleWithCredentialsMethod · 0.80
isSameProjectionMethod · 0.45
fireMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected