septima-widget 3.4.1 → 3.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/widgetapi.mjs +82 -76
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "septima-widget",
3
- "version": "3.4.1",
3
+ "version": "3.4.3",
4
4
  "description": "Septima Widget API",
5
5
  "type": "module",
6
6
  "module": "./widgetapi.mjs",
package/widgetapi.mjs CHANGED
@@ -1,12 +1,11 @@
1
1
  export default class WidgetAPI {
2
-
3
2
  _readylisteners = []
4
3
  _controlsreadylisteners = []
5
4
  _vectorreadylisteners = []
6
5
 
7
6
  _target = null
8
7
 
9
- VERSION = '3.4.1'
8
+ VERSION = '3.4.3'
10
9
 
11
10
  constructor(target, config, options) {
12
11
  this._target = target
@@ -14,8 +13,8 @@ export default class WidgetAPI {
14
13
  }
15
14
 
16
15
  async _load(target, config, options) {
17
- const { load } = await import('https://widget.cdn.septima.dk/3.4.1/core/load.mjs')
18
- this._widget = await load(target, config, options, this.VERSION)
16
+ const { load } = await import('https://widget.cdn.septima.dk/3.4.3/core/load.mjs')
17
+ this._widget = await load(target, config, options, this)
19
18
  this.on('controlsready', () => {
20
19
  this._controlsReady()
21
20
  })
@@ -30,175 +29,182 @@ export default class WidgetAPI {
30
29
  _ready(func) {
31
30
  if (!this._widget || typeof this._widget.events === 'undefined') {
32
31
  if (func) {
33
- this._readylisteners.push(func);
32
+ this._readylisteners.push(func)
34
33
  }
35
34
  } else {
36
35
  if (func) {
37
- func();
36
+ func()
38
37
  } else {
39
38
  for (var i = 0; i < this._readylisteners.length; i++) {
40
- this._readylisteners[i]();
39
+ this._readylisteners[i]()
41
40
  }
42
41
  }
43
42
  }
44
- };
43
+ this._widget.events.fireEvent('ready', this)
44
+ }
45
45
 
46
46
  _controlsReady(func) {
47
47
  if (func) {
48
48
  if (this._controlsAreReady) {
49
- func();
49
+ func()
50
50
  } else {
51
- this._controlsreadylisteners.push(func);
51
+ this._controlsreadylisteners.push(func)
52
52
  }
53
53
  } else {
54
- this._controlsAreReady = true;
54
+ this._controlsAreReady = true
55
55
  for (var i = 0; i < this._controlsreadylisteners.length; i++) {
56
- this._controlsreadylisteners[i]();
56
+ this._controlsreadylisteners[i]()
57
57
  }
58
58
  }
59
- };
59
+ }
60
60
 
61
61
  _vectorsReady(func) {
62
62
  if (func) {
63
63
  if (this._vectorsAreReady) {
64
- func();
64
+ func()
65
65
  } else {
66
- this._vectorreadylisteners.push(func);
66
+ this._vectorreadylisteners.push(func)
67
67
  }
68
68
  } else {
69
- this._vectorsAreReady = true;
69
+ this._vectorsAreReady = true
70
70
  for (var i = 0; i < this._vectorreadylisteners.length; i++) {
71
- this._vectorreadylisteners[i]();
71
+ this._vectorreadylisteners[i]()
72
72
  }
73
73
  }
74
- };
74
+ }
75
75
 
76
76
  async _setConfig(config = {}, options = {}) {
77
- this._vectorsAreReady = false;
78
- this._controlsAreReady = false;
77
+ this._vectorsAreReady = false
78
+ this._controlsAreReady = false
79
79
  this._load(this._target, config, options)
80
- };
80
+ }
81
81
 
82
82
  getURLParam(name) {
83
- return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [undefined, ""])[1].replace(/\+/g, '%20')) || null;
84
- };
83
+ return (
84
+ decodeURIComponent(
85
+ (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [
86
+ undefined,
87
+ ''
88
+ ])[1].replace(/\+/g, '%20')
89
+ ) || null
90
+ )
91
+ }
85
92
 
86
93
  bind(func, object) {
87
- var args = Array.prototype.slice.apply(arguments, [2]);
94
+ var args = Array.prototype.slice.apply(arguments, [2])
88
95
  return function () {
89
- var newArgs = args.concat(
90
- Array.prototype.slice.apply(arguments, [0])
91
- );
92
- return func.apply(object, newArgs);
93
- };
94
- };
96
+ var newArgs = args.concat(Array.prototype.slice.apply(arguments, [0]))
97
+ return func.apply(object, newArgs)
98
+ }
99
+ }
95
100
 
96
101
  setConfig(config, options) {
97
102
  if (this._widget) {
98
- this._setConfig(config, options);
103
+ this._setConfig(config, options)
99
104
  } else {
100
- this._ready(() => this._setConfig(config, options));
105
+ this._ready(() => this._setConfig(config, options))
101
106
  }
102
- };
107
+ }
103
108
 
104
109
  on(event, callback) {
105
110
  if (this._widget && typeof this._widget.events !== 'undefined') {
106
- this._widget.events.on(event, callback);
111
+ this._widget.events.on(event, callback)
107
112
  } else {
108
- this._ready(() => this._widget.events.on(event, callback));
113
+ this._ready(() => this._widget.events.on(event, callback))
109
114
  }
110
- };
115
+ }
111
116
 
112
117
  addData(config, options, silen) {
113
- this._vectorsReady(() => this._widget.addData(config, options, silen));
114
- };
118
+ this._vectorsReady(() => this._widget.addData(config, options, silen))
119
+ }
115
120
 
116
121
  removeData(id) {
117
- this._vectorsReady(() => this._widget.removeData(id));
118
- };
122
+ this._vectorsReady(() => this._widget.removeData(id))
123
+ }
119
124
 
120
125
  addSelect(geojson, options, silent) {
121
126
  if (typeof options !== 'undefined' && typeof options.activateZoom === 'undefined') {
122
- options.activateZoom = true;
127
+ options.activateZoom = true
123
128
  }
124
- this._controlsReady(() => this._widget.addSelect(geojson, options, silent));
125
- };
129
+ this._controlsReady(() => this._widget.addSelect(geojson, options, silent))
130
+ }
126
131
 
127
132
  removeSelect(silent) {
128
- this._controlsReady(() => this._widget.removeSelect(silent));
129
- };
133
+ this._controlsReady(() => this._widget.removeSelect(silent))
134
+ }
130
135
 
131
136
  setView(options) {
132
- this._controlsReady(() => this._widget.setView(options));
133
- };
137
+ this._controlsReady(() => this._widget.setView(options))
138
+ }
134
139
 
135
140
  getView(srs) {
136
141
  if (this._widget) {
137
142
  return this._widget.getView(srs)
138
143
  }
139
144
  return null
140
- };
145
+ }
141
146
 
142
147
  selectFeatureInLayer(layerId, filterFunction, options, silent) {
143
148
  if (typeof options !== 'undefined' && typeof options.activateZoom === 'undefined') {
144
- options.activateZoom = true;
149
+ options.activateZoom = true
145
150
  }
146
- this._vectorsReady(() => this._widget.selectFeatureInLayer(layerId, filterFunction, options, silent));
147
- };
151
+ this._vectorsReady(() =>
152
+ this._widget.selectFeatureInLayer(layerId, filterFunction, options, silent)
153
+ )
154
+ }
148
155
 
149
156
  deselectFeature(silent) {
150
- this._vectorsReady(() => this._widget.deselectFeature(silent));
151
- };
157
+ this._vectorsReady(() => this._widget.deselectFeature(silent))
158
+ }
152
159
 
153
160
  showLayer(layerId) {
154
- this._controlsReady(() => this._widget.showLayer(layerId));
155
- };
161
+ this._controlsReady(() => this._widget.showLayer(layerId))
162
+ }
156
163
 
157
164
  hideLayer(layerId) {
158
- this._controlsReady(() => this._widget.hideLayer(layerId));
159
- };
165
+ this._controlsReady(() => this._widget.hideLayer(layerId))
166
+ }
160
167
 
161
168
  setLayerOpacity(layerId, opacity) {
162
- this._controlsReady(() => this._widget.setLayerOpacity(layerId, opacity));
163
- };
169
+ this._controlsReady(() => this._widget.setLayerOpacity(layerId, opacity))
170
+ }
164
171
 
165
172
  reloadLayer(layerId) {
166
- this._controlsReady(() => this._widget.reloadLayer(layerId));
167
- };
173
+ this._controlsReady(() => this._widget.reloadLayer(layerId))
174
+ }
168
175
 
169
176
  updateLayerParams(layerId, params) {
170
- this._controlsReady(() => this._widget.updateLayerParams(layerId, params));
171
- };
177
+ this._controlsReady(() => this._widget.updateLayerParams(layerId, params))
178
+ }
172
179
 
173
180
  showPopup(geojson, html, options) {
174
- this._controlsReady(() => this._widget.showPopup(geojson, html, options));
175
- };
181
+ this._controlsReady(() => this._widget.showPopup(geojson, html, options))
182
+ }
176
183
 
177
184
  hidePopup() {
178
- this._controlsReady(() => this._widget.hidePopup());
179
- };
185
+ this._controlsReady(() => this._widget.hidePopup())
186
+ }
180
187
 
181
188
  draw(options, callback, sketchCallback) {
182
- this._controlsReady(() => this._widget.draw(options, callback, sketchCallback));
183
- };
189
+ this._controlsReady(() => this._widget.draw(options, callback, sketchCallback))
190
+ }
184
191
 
185
192
  unDraw() {
186
- this._controlsReady(() => this._widget.unDraw());
187
- };
193
+ this._controlsReady(() => this._widget.unDraw())
194
+ }
188
195
 
189
196
  createMapImage(options, callback) {
190
- this._controlsReady(() => this._widget.createMapImage(options, callback));
197
+ this._controlsReady(() => this._widget.createMapImage(options, callback))
191
198
  }
192
199
 
193
200
  transform(geojson, options, callback) {
194
201
  this._controlsReady(async () => {
195
- const { transform } = await import('https://widget.cdn.septima.dk/3.4.1/core/utils.mjs')
202
+ const { transform } = await import('https://widget.cdn.septima.dk/3.4.3/core/utils.mjs')
196
203
  if (callback) {
197
- callback(transform(geojson, options));
204
+ callback(transform(geojson, options))
198
205
  } else {
199
206
  transform(geojson, options)
200
207
  }
201
- });
208
+ })
202
209
  }
203
-
204
210
  }