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

Function createMapStyleExtending

src/common/mapping/MapStyle.js:5–184  ·  view source on GitHub ↗
(SuperClass, { MapManager, crsManager })

Source from the content-addressed store, hash-verified

3import { createAppreciableLayerId, isSameRasterLayer } from './utils/util';
4
5export function createMapStyleExtending(SuperClass, { MapManager, crsManager }) {
6 return class MapStyle extends SuperClass {
7 constructor(id, options = {}, mapOptions = {}) {
8 super();
9 this.options = options;
10 this.mapOptions = mapOptions;
11 this.webMapService = new WebMapService(id, options);
12 this._layerIdRenameMapList = [];
13 this._appendLayers = false;
14 this._baseProjection = '';
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) {

Callers 2

_createWebMapFactoryMethod · 0.90
_createWebMapFactoryMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected