septima-widget 3.4.1 → 3.4.2

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