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

Function Map

test/tool/mock_mapboxgl_map.js:23–425  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

21}
22
23const Map = function (options) {
24 const evented = new mapboxgl.Evented();
25 this.on = evented.on;
26 this.once = evented.once;
27 this._update = () => {};
28 this.fire = evented.fire;
29 this.listens = evented.listens;
30
31 this.options = options;
32 this._events = {};
33 this._sources = {};
34 this._collectResourceTiming = !!this.options.collectResourceTiming;
35 this.zoom = this.options.zoom || 0;
36 this.maxZoom = this.options.maxZoom || 22;
37 this._container = this.options.container || 'map';
38 this._layers = {};
39 this._layersList = [];
40 this.getContainer = function () {
41 return this._container;
42 };
43 this.bounds = this.options.bounds;
44
45 try {
46 this.center = this.options.center
47 ? new mapboxgl.LngLat(this.options.center.lng, this.options.center.lat)
48 : new mapboxgl.LngLat(0, 0);
49 } catch (e) {
50 this.center = this.options.center
51 ? new mapboxgl.LngLat(this.options.center[0], this.options.center[1])
52 : new mapboxgl.LngLat(0, 0);
53 }
54 this.resize = jasmine.createSpy('resize').and.callFake(() => {});
55 this.style = {
56 ...options.style,
57 addGlyphs: jasmine.createSpy('addGlyphs').and.callFake(() => {}),
58 addSprite: jasmine.createSpy('addSprite').and.callFake(() => {}),
59 _layers: this._layers
60 };
61 this.setStyle = function (style, options) {
62 if (style.layers) {
63 style.layers.forEach((layer) => {
64 this._layers[layer.id] = layer;
65 if (layer.source instanceof Object) {
66 this.addSource(layer.id, Object.assign({}, layer.source));
67 this._layers[layer.id].source = layer.id;
68 }
69 if (!this._layersList.find((item) => item.id === layer.id)) {
70 this._layersList.push(layer);
71 }
72 if (layer.onAdd) {
73 layer.onAdd(this);
74 }
75 if (layer.render) {
76 layer.render();
77 }
78 this.fire('styledata');
79 return this;
80 });

Callers

nothing calls this directly

Calls 15

forEachMethod · 0.80
addSourceMethod · 0.80
pushMethod · 0.80
drawImageCallbackMethod · 0.80
convertMethod · 0.80
functorFunction · 0.70
onAddMethod · 0.65
renderMethod · 0.65
callbackFunction · 0.50
findMethod · 0.45
fireMethod · 0.45
setStyleMethod · 0.45

Tested by

no test coverage detected