(options)
| 21 | } |
| 22 | |
| 23 | const 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 | }); |
nothing calls this directly
no test coverage detected