maplibre-gl-js-amplify 3.0.5 → 4.0.0

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 (70) hide show
  1. package/dist/maplibre-gl-js-amplify.umd.js +479 -461
  2. package/dist/maplibre-gl-js-amplify.umd.min.js +1 -1
  3. package/dist/maplibre-gl-js-amplify.umd.min.js.gz +0 -0
  4. package/dist/public/amplify-ctrl-geofence.css +1 -1
  5. package/lib/cjs/AmplifyGeofenceControl/AmplifyMapDraw.d.ts +3 -3
  6. package/lib/cjs/AmplifyGeofenceControl/AmplifyMapDraw.js +31 -31
  7. package/lib/cjs/AmplifyGeofenceControl/icons.js +117 -117
  8. package/lib/cjs/AmplifyGeofenceControl/index.d.ts +4 -4
  9. package/lib/cjs/AmplifyGeofenceControl/index.js +22 -21
  10. package/lib/cjs/AmplifyGeofenceControl/ui.d.ts +2 -2
  11. package/lib/cjs/AmplifyGeofenceControl/ui.js +130 -130
  12. package/lib/cjs/AmplifyMapLibreGeocoder.d.ts +1 -1
  13. package/lib/cjs/AmplifyMapLibreGeocoder.js +11 -10
  14. package/lib/cjs/AmplifyMapLibreRequest.d.ts +5 -5
  15. package/lib/cjs/AmplifyMapLibreRequest.js +28 -14
  16. package/lib/cjs/constants.js +17 -17
  17. package/lib/cjs/createDefaultIcon.js +12 -12
  18. package/lib/cjs/createMarker.d.ts +1 -1
  19. package/lib/cjs/createMarker.js +2 -2
  20. package/lib/cjs/drawClusterLayer.d.ts +2 -2
  21. package/lib/cjs/drawClusterLayer.js +17 -17
  22. package/lib/cjs/drawGeofences.d.ts +2 -2
  23. package/lib/cjs/drawGeofences.js +20 -20
  24. package/lib/cjs/drawPoints.d.ts +4 -4
  25. package/lib/cjs/drawPoints.js +12 -12
  26. package/lib/cjs/drawUnclusteredLayer.d.ts +2 -2
  27. package/lib/cjs/drawUnclusteredLayer.js +23 -23
  28. package/lib/cjs/geofenceUtils.d.ts +3 -3
  29. package/lib/cjs/geofenceUtils.js +15 -15
  30. package/lib/cjs/index.d.ts +6 -6
  31. package/lib/cjs/popupRender.d.ts +1 -1
  32. package/lib/cjs/popupRender.js +5 -5
  33. package/lib/cjs/public/amplify-ctrl-geofence.css +1 -1
  34. package/lib/cjs/types.d.ts +1 -1
  35. package/lib/cjs/utils.d.ts +3 -3
  36. package/lib/cjs/utils.js +17 -15
  37. package/lib/esm/AmplifyGeofenceControl/AmplifyMapDraw.d.ts +3 -3
  38. package/lib/esm/AmplifyGeofenceControl/AmplifyMapDraw.js +35 -35
  39. package/lib/esm/AmplifyGeofenceControl/icons.js +117 -117
  40. package/lib/esm/AmplifyGeofenceControl/index.d.ts +4 -4
  41. package/lib/esm/AmplifyGeofenceControl/index.js +30 -29
  42. package/lib/esm/AmplifyGeofenceControl/ui.d.ts +2 -2
  43. package/lib/esm/AmplifyGeofenceControl/ui.js +134 -134
  44. package/lib/esm/AmplifyMapLibreGeocoder.d.ts +1 -1
  45. package/lib/esm/AmplifyMapLibreGeocoder.js +15 -14
  46. package/lib/esm/AmplifyMapLibreRequest.d.ts +5 -5
  47. package/lib/esm/AmplifyMapLibreRequest.js +29 -15
  48. package/lib/esm/constants.js +17 -17
  49. package/lib/esm/createDefaultIcon.js +13 -13
  50. package/lib/esm/createMarker.d.ts +1 -1
  51. package/lib/esm/createMarker.js +3 -3
  52. package/lib/esm/drawClusterLayer.d.ts +2 -2
  53. package/lib/esm/drawClusterLayer.js +21 -21
  54. package/lib/esm/drawGeofences.d.ts +2 -2
  55. package/lib/esm/drawGeofences.js +23 -23
  56. package/lib/esm/drawPoints.d.ts +4 -4
  57. package/lib/esm/drawPoints.js +15 -15
  58. package/lib/esm/drawUnclusteredLayer.d.ts +2 -2
  59. package/lib/esm/drawUnclusteredLayer.js +27 -27
  60. package/lib/esm/geofenceUtils.d.ts +3 -3
  61. package/lib/esm/geofenceUtils.js +20 -20
  62. package/lib/esm/index.d.ts +6 -6
  63. package/lib/esm/index.js +6 -6
  64. package/lib/esm/popupRender.d.ts +1 -1
  65. package/lib/esm/popupRender.js +7 -7
  66. package/lib/esm/public/amplify-ctrl-geofence.css +1 -1
  67. package/lib/esm/types.d.ts +1 -1
  68. package/lib/esm/utils.d.ts +3 -3
  69. package/lib/esm/utils.js +17 -15
  70. package/package.json +29 -19
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@aws-amplify/core'), require('@aws-amplify/geo'), require('maplibre-gl'), require('@maplibre/maplibre-gl-geocoder'), require('@turf/along'), require('@turf/circle'), require('@turf/length'), require('@turf/helpers'), require('debounce'), require('@mapbox/mapbox-gl-draw'), require('maplibre-gl-draw-circle')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@aws-amplify/core', '@aws-amplify/geo', 'maplibre-gl', '@maplibre/maplibre-gl-geocoder', '@turf/along', '@turf/circle', '@turf/length', '@turf/helpers', 'debounce', '@mapbox/mapbox-gl-draw', 'maplibre-gl-draw-circle'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AmplifyMapLibre = {}, global.aws_amplify_core, global.aws_amplify_geo, global.maplibregl, global.MaplibreGeocoder, global.along, global.circle, global.length, global.helpers, global.debounce, global.MapboxDraw, global.maplibreGlDrawCircle));
5
- })(this, (function (exports, core, geo, maplibregl, MaplibreGeocoder, along, circle, length, helpers, debounce, MapboxDraw, maplibreGlDrawCircle) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@aws-amplify/core'), require('@aws-amplify/core/internals/utils'), require('@aws-amplify/geo'), require('maplibre-gl'), require('@maplibre/maplibre-gl-geocoder'), require('@turf/along'), require('@turf/circle'), require('@turf/length'), require('@turf/helpers'), require('debounce'), require('@mapbox/mapbox-gl-draw'), require('maplibre-gl-draw-circle')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@aws-amplify/core', '@aws-amplify/core/internals/utils', '@aws-amplify/geo', 'maplibre-gl', '@maplibre/maplibre-gl-geocoder', '@turf/along', '@turf/circle', '@turf/length', '@turf/helpers', 'debounce', '@mapbox/mapbox-gl-draw', 'maplibre-gl-draw-circle'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AmplifyMapLibre = {}, global.aws_amplify_core, global.utils, global.aws_amplify_geo, global.maplibregl, global.MaplibreGeocoder, global.along, global.circle, global.length, global.helpers, global.debounce, global.MapboxDraw, global.maplibreGlDrawCircle));
5
+ })(this, (function (exports, core, utils, geo, maplibregl, MaplibreGeocoder, along, circle, length, helpers, debounce, MapboxDraw, maplibreGlDrawCircle) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -15,8 +15,8 @@
15
15
 
16
16
  function isCoordinates(array) {
17
17
  return (Array.isArray(array) &&
18
- typeof array[0] === "number" &&
19
- typeof array[1] === "number");
18
+ typeof array[0] === 'number' &&
19
+ typeof array[1] === 'number');
20
20
  }
21
21
  function isCoordinatesArray(array) {
22
22
  return isCoordinates(array[0]);
@@ -24,16 +24,16 @@
24
24
  function isNamedLocation(object) {
25
25
  return (object &&
26
26
  Array.isArray(object.coordinates) &&
27
- typeof object.coordinates[0] === "number" &&
28
- typeof object.coordinates[1] === "number");
27
+ typeof object.coordinates[0] === 'number' &&
28
+ typeof object.coordinates[1] === 'number');
29
29
  }
30
30
  function isNamedLocationArray(array) {
31
31
  return isNamedLocation(array[0]);
32
32
  }
33
33
  function isGeofence(object) {
34
34
  return (object &&
35
- typeof object.geofenceId === "string" &&
36
- typeof object.geometry === "object");
35
+ typeof object.geofenceId === 'string' &&
36
+ typeof object.geometry === 'object');
37
37
  }
38
38
  function isGeofenceArray(array) {
39
39
  return Array.isArray(array) && isGeofence(array[0]);
@@ -45,16 +45,16 @@
45
45
  return Array.isArray(array) && isPolygon(array[0]);
46
46
  }
47
47
  function isGeoJsonSource(source) {
48
- return source.type === "geojson";
48
+ return source.type === 'geojson';
49
49
  }
50
- const strHasLength = (str) => typeof str === "string" && str.length > 0;
50
+ const strHasLength = (str) => typeof str === 'string' && str.length > 0;
51
51
  const getFeaturesFromData = (data) => {
52
52
  let features;
53
53
  if (isCoordinatesArray(data)) {
54
54
  features = data.map((point) => {
55
55
  return {
56
- type: "Feature",
57
- geometry: { type: "Point", coordinates: point },
56
+ type: 'Feature',
57
+ geometry: { type: 'Point', coordinates: point },
58
58
  properties: { place_name: `Coordinates,${point}` },
59
59
  };
60
60
  });
@@ -62,8 +62,8 @@
62
62
  else if (isNamedLocationArray(data)) {
63
63
  features = data.map((location) => {
64
64
  return {
65
- type: "Feature",
66
- geometry: { type: "Point", coordinates: location.coordinates },
65
+ type: 'Feature',
66
+ geometry: { type: 'Point', coordinates: location.coordinates },
67
67
  properties: { title: location.title, address: location.address },
68
68
  };
69
69
  });
@@ -74,7 +74,7 @@
74
74
  return features;
75
75
  };
76
76
  const urlEncodePeriods = (str) => {
77
- return str.replace(/\./g, "%2E");
77
+ return str.replace(/\./g, '%2E');
78
78
  };
79
79
  function validateCoordinates(coordinates) {
80
80
  const [lng, lat] = coordinates;
@@ -82,12 +82,14 @@
82
82
  throw new Error(`Invalid coordinates: [${lng},${lat}]`);
83
83
  }
84
84
  if (lat < -90 || lat > 90) {
85
- const errorString = "Latitude must be between -90 and 90 degrees inclusive.";
85
+ const errorString = 'Latitude must be between -90 and 90 degrees inclusive.';
86
+ // eslint-disable-next-line no-console
86
87
  console.warn(errorString);
87
88
  throw new Error(errorString);
88
89
  }
89
90
  else if (lng < -180 || lng > 180) {
90
- const errorString = "Longitude must be between -180 and 180 degrees inclusive.";
91
+ const errorString = 'Longitude must be between -180 and 180 degrees inclusive.';
92
+ // eslint-disable-next-line no-console
91
93
  console.warn(errorString);
92
94
  throw new Error(errorString);
93
95
  }
@@ -138,9 +140,10 @@
138
140
  constructor(currentCredentials, region) {
139
141
  this.refreshCredentials = () => __awaiter$3(this, void 0, void 0, function* () {
140
142
  try {
141
- this.credentials = yield core.Credentials.get();
143
+ this.credentials = (yield core.fetchAuthSession()).credentials;
142
144
  }
143
145
  catch (e) {
146
+ // eslint-disable-next-line no-console
144
147
  console.error(`Failed to refresh credentials: ${e}`);
145
148
  throw e;
146
149
  }
@@ -148,11 +151,11 @@
148
151
  this.refreshCredentialsWithRetry = () => __awaiter$3(this, void 0, void 0, function* () {
149
152
  try {
150
153
  const MAX_DELAY_MS = 5 * 60 * 1000; // 5 minutes
151
- yield core.jitteredExponentialRetry(this.refreshCredentials, [], MAX_DELAY_MS);
154
+ yield utils.jitteredExponentialRetry(this.refreshCredentials, [], MAX_DELAY_MS);
152
155
  // Refresh credentials on a timer because HubEvents do not trigger on credential refresh currently
153
156
  this.activeTimeout && clearTimeout(this.activeTimeout);
154
157
  // Refresh credentials when expiration time is later than now
155
- if (this.credentials.expiration.getTime() > (new Date()).getTime()) {
158
+ if (this.credentials.expiration.getTime() > new Date().getTime()) {
156
159
  const expiration = new Date(this.credentials.expiration);
157
160
  const timeout = expiration.getTime() - new Date().getTime() - 10000; // Adds a 10 second buffer time before the next refresh
158
161
  this.activeTimeout = window.setTimeout(this.refreshCredentialsWithRetry, Math.min(timeout, 3600000) // Set timeout to an hour if we somehow don't have a value for timeout
@@ -160,6 +163,7 @@
160
163
  }
161
164
  }
162
165
  catch (e) {
166
+ // eslint-disable-next-line no-console
163
167
  console.error(`Failed to refresh credentials: ${e}`);
164
168
  }
165
169
  });
@@ -171,18 +175,18 @@
171
175
  */
172
176
  this.transformRequest = (url, resourceType) => {
173
177
  let styleUrl = url;
174
- if (resourceType === "Style" && !url.includes("://")) {
178
+ if (resourceType === 'Style' && !url.includes('://')) {
175
179
  if (this.region == undefined) {
176
- throw new Error("AWS region for map is undefined. Please verify that the region is set in aws-exports.js or that you are providing an AWS region parameter to createMap");
180
+ throw new Error('AWS region for map is undefined. Please verify that the region is set in aws-exports.js or that you are providing an AWS region parameter to createMap');
177
181
  }
178
182
  styleUrl = `https://maps.geo.${this.region}.amazonaws.com/maps/v0/maps/${url}/style-descriptor`;
179
183
  }
180
184
  const urlObject = new URL(styleUrl);
181
- if (urlObject.hostname.endsWith(".amazonaws.com")) {
185
+ if (urlObject.hostname.endsWith('.amazonaws.com')) {
182
186
  // only sign AWS requests (with the signature as part of the query string)
183
- urlObject.searchParams.append('x-amz-user-agent', encodeURIComponent(urlEncodePeriods(core.getAmplifyUserAgent())));
187
+ urlObject.searchParams.append('x-amz-user-agent', encodeURIComponent(urlEncodePeriods(getAmplifyUserAgentString())));
184
188
  return {
185
- url: core.Signer.signUrl(urlObject.href, {
189
+ url: utils.Signer.signUrl(urlObject.href, {
186
190
  access_key: this.credentials.accessKeyId,
187
191
  secret_key: this.credentials.secretAccessKey,
188
192
  session_token: this.credentials.sessionToken,
@@ -194,11 +198,12 @@
194
198
  this.region = region;
195
199
  this.activeTimeout = null;
196
200
  this.refreshCredentialsWithRetry();
197
- core.Hub.listen("auth", (data) => {
201
+ core.Hub.listen('auth', (data) => {
198
202
  switch (data.payload.event) {
199
- case "signIn":
200
- case "signOut":
201
- case "tokenRefresh":
203
+ // This was removed from v6 but will be added back before GA
204
+ case 'signedIn':
205
+ case 'signedOut':
206
+ case 'tokenRefresh':
202
207
  this.refreshCredentialsWithRetry();
203
208
  break;
204
209
  }
@@ -208,7 +213,7 @@
208
213
  AmplifyMapLibreRequest.createMapLibreMap = (options) => __awaiter$3(void 0, void 0, void 0, function* () {
209
214
  const { region, mapConstructor = maplibregl.Map } = options, maplibreOption = __rest$2(options, ["region", "mapConstructor"]);
210
215
  const defaultMap = geo.Geo.getDefaultMap();
211
- const amplifyRequest = new AmplifyMapLibreRequest(yield core.Credentials.get(), region || defaultMap.region);
216
+ const amplifyRequest = new AmplifyMapLibreRequest((yield core.fetchAuthSession()).credentials, region || defaultMap.region);
212
217
  const transformRequest = amplifyRequest.transformRequest;
213
218
  const map = new mapConstructor(Object.assign(Object.assign({}, maplibreOption), { style: options.style || defaultMap.mapName, // Amplify uses the name of the map in the maplibre style field,
214
219
  transformRequest }));
@@ -217,16 +222,26 @@
217
222
  const createMap = (options) => __awaiter$3(void 0, void 0, void 0, function* () {
218
223
  return AmplifyMapLibreRequest.createMapLibreMap(options);
219
224
  });
225
+ // TODO - Delete this and import from @aws-amplify/core when it is released
226
+ function getAmplifyUserAgentString() {
227
+ const userAgent = utils.getAmplifyUserAgent();
228
+ if (userAgent && typeof userAgent === 'object') {
229
+ return userAgent
230
+ .map(([agentKey, agentValue]) => `${agentKey}/${agentValue}`)
231
+ .join(' ');
232
+ }
233
+ return userAgent;
234
+ }
220
235
 
221
- const COLOR_WHITE = "#fff";
222
- const COLOR_BLACK = "#000";
223
- const MARKER_COLOR = "#5d8aff";
224
- const ACTIVE_MARKER_COLOR = "#ff9900";
225
- const POPUP_BORDER_COLOR = "#0000001f";
226
- const GEOFENCE_COLOR = "#2194f3";
227
- const GEOFENCE_BORDER_COLOR = "#003560";
228
- const GEOFENCE_VERTEX_COLOR = "#FF9900";
229
- const LOCATION_MARKER = "M24.8133 38.533C18.76 31.493 13 28.8264 13 20.8264C13.4827 14.9864 16.552 9.67169 21.368 6.33302C33.768 -2.26165 50.824 5.78902 52.0667 20.8264C52.0667 28.613 46.5733 31.6797 40.6533 38.373C32.4933 47.5464 35.4 63.093 32.4933 63.093C29.72 63.093 32.4933 47.5464 24.8133 38.533ZM32.4933 8.23969C26.5573 8.23969 21.7467 13.0504 21.7467 18.9864C21.7467 24.9224 26.5573 29.733 32.4933 29.733C38.4293 29.733 43.24 24.9224 43.24 18.9864C43.24 13.0504 38.4293 8.23969 32.4933 8.23969Z";
236
+ const COLOR_WHITE = '#fff';
237
+ const COLOR_BLACK = '#000';
238
+ const MARKER_COLOR = '#5d8aff';
239
+ const ACTIVE_MARKER_COLOR = '#ff9900';
240
+ const POPUP_BORDER_COLOR = '#0000001f';
241
+ const GEOFENCE_COLOR = '#2194f3';
242
+ const GEOFENCE_BORDER_COLOR = '#003560';
243
+ const GEOFENCE_VERTEX_COLOR = '#FF9900';
244
+ const LOCATION_MARKER = 'M24.8133 38.533C18.76 31.493 13 28.8264 13 20.8264C13.4827 14.9864 16.552 9.67169 21.368 6.33302C33.768 -2.26165 50.824 5.78902 52.0667 20.8264C52.0667 28.613 46.5733 31.6797 40.6533 38.373C32.4933 47.5464 35.4 63.093 32.4933 63.093C29.72 63.093 32.4933 47.5464 24.8133 38.533ZM32.4933 8.23969C26.5573 8.23969 21.7467 13.0504 21.7467 18.9864C21.7467 24.9224 26.5573 29.733 32.4933 29.733C38.4293 29.733 43.24 24.9224 43.24 18.9864C43.24 13.0504 38.4293 8.23969 32.4933 8.23969Z';
230
245
  // Map styles exist due to an issue with Amazon Location Service not supporting the default set of maplibre fonts
231
246
  var MAP_STYLES;
232
247
  (function (MAP_STYLES) {
@@ -238,21 +253,21 @@
238
253
  MAP_STYLES["HERE_BERLIN"] = "VectorHereBerlin";
239
254
  })(MAP_STYLES || (MAP_STYLES = {}));
240
255
  const FONT_DEFAULT_BY_STYLE = {
241
- [MAP_STYLES.ESRI_TOPOGRAPHIC]: "Noto Sans Regular",
242
- [MAP_STYLES.ESRI_STREETS]: "Arial Regular",
243
- [MAP_STYLES.ESRI_LIGHT_GRAY]: "Ubuntu Regular",
244
- [MAP_STYLES.ESRI_DARK_GRAY]: "Ubuntu Regular",
245
- [MAP_STYLES.ESRI_NAVIGATION]: "Arial Regular",
246
- [MAP_STYLES.HERE_BERLIN]: "Fira GO Regular",
256
+ [MAP_STYLES.ESRI_TOPOGRAPHIC]: 'Noto Sans Regular',
257
+ [MAP_STYLES.ESRI_STREETS]: 'Arial Regular',
258
+ [MAP_STYLES.ESRI_LIGHT_GRAY]: 'Ubuntu Regular',
259
+ [MAP_STYLES.ESRI_DARK_GRAY]: 'Ubuntu Regular',
260
+ [MAP_STYLES.ESRI_NAVIGATION]: 'Arial Regular',
261
+ [MAP_STYLES.HERE_BERLIN]: 'Fira GO Regular',
247
262
  };
248
263
 
249
264
  function drawClusterLayer(sourceName, map, { fillColor: markerColor = MARKER_COLOR, smCircleSize: smallSize = 60, smThreshold: smallThreshold = 50, mdCircleSize: mediumSize = 100, mdThreshold: mediumThreshold = 100, lgCircleSize: largeSize = 140, lgThreshold: largeThreshold = 500, xlCircleSize: extraLargeSize = 180, borderWidth = 4, borderColor = COLOR_WHITE, clusterPaint, onClick, showCount, clusterCountLayout, fontColor = COLOR_WHITE, }, mapStyle) {
250
265
  const clusterLayerId = `${sourceName}-layer-clusters`;
251
266
  const clusterSymbolLayerId = `${sourceName}-layer-cluster-count`;
252
267
  // Use step expressions for clusters (https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-step)
253
- const paintOptions = Object.assign({ "circle-color": [
254
- "step",
255
- ["get", "point_count"],
268
+ const paintOptions = Object.assign({ 'circle-color': [
269
+ 'step',
270
+ ['get', 'point_count'],
256
271
  markerColor,
257
272
  smallThreshold,
258
273
  markerColor,
@@ -260,9 +275,9 @@
260
275
  markerColor,
261
276
  largeThreshold,
262
277
  markerColor,
263
- ], "circle-radius": [
264
- "step",
265
- ["get", "point_count"],
278
+ ], 'circle-radius': [
279
+ 'step',
280
+ ['get', 'point_count'],
266
281
  smallSize,
267
282
  smallThreshold,
268
283
  mediumSize,
@@ -270,20 +285,20 @@
270
285
  largeSize,
271
286
  largeThreshold,
272
287
  extraLargeSize,
273
- ], "circle-stroke-width": borderWidth, "circle-stroke-color": borderColor }, clusterPaint);
288
+ ], 'circle-stroke-width': borderWidth, 'circle-stroke-color': borderColor }, clusterPaint);
274
289
  const defaultClusterLayer = {
275
290
  id: clusterLayerId,
276
- type: "circle",
291
+ type: 'circle',
277
292
  source: sourceName,
278
- filter: ["has", "point_count"],
293
+ filter: ['has', 'point_count'],
279
294
  paint: paintOptions,
280
295
  };
281
296
  map.addLayer(Object.assign({}, defaultClusterLayer));
282
297
  /*
283
298
  * Inspect cluster on click
284
299
  */
285
- map.on("click", clusterLayerId, function (e) {
286
- if (typeof onClick === "function")
300
+ map.on('click', clusterLayerId, function (e) {
301
+ if (typeof onClick === 'function')
287
302
  onClick(e);
288
303
  const features = map.queryRenderedFeatures(e.point, {
289
304
  layers: [clusterLayerId],
@@ -306,24 +321,24 @@
306
321
  */
307
322
  if (showCount) {
308
323
  const defaultLayoutOptions = {
309
- "text-field": "{point_count_abbreviated}",
310
- "text-size": 24,
324
+ 'text-field': '{point_count_abbreviated}',
325
+ 'text-size': 24,
311
326
  };
312
327
  const locationServiceStyle = mapStyle || geo.Geo.getDefaultMap().style;
313
328
  if (locationServiceStyle) {
314
- defaultLayoutOptions["text-font"] = [
329
+ defaultLayoutOptions['text-font'] = [
315
330
  FONT_DEFAULT_BY_STYLE[locationServiceStyle],
316
331
  ];
317
332
  }
318
333
  const layoutOptions = Object.assign(Object.assign({}, defaultLayoutOptions), clusterCountLayout);
319
334
  const paintOptions = {
320
- "text-color": fontColor,
335
+ 'text-color': fontColor,
321
336
  };
322
337
  const defaultClusterCount = {
323
338
  id: clusterSymbolLayerId,
324
- type: "symbol",
339
+ type: 'symbol',
325
340
  source: sourceName,
326
- filter: ["has", "point_count"],
341
+ filter: ['has', 'point_count'],
327
342
  layout: layoutOptions,
328
343
  paint: paintOptions,
329
344
  };
@@ -341,10 +356,10 @@
341
356
  height: 64,
342
357
  data: new Uint8Array(64 * 64 * 4),
343
358
  onAdd: function () {
344
- const canvas = document.createElement("canvas");
359
+ const canvas = document.createElement('canvas');
345
360
  canvas.width = this.width;
346
361
  canvas.height = this.height;
347
- this.context = canvas.getContext("2d");
362
+ this.context = canvas.getContext('2d');
348
363
  },
349
364
  render: function () {
350
365
  const context = this.context;
@@ -360,14 +375,14 @@
360
375
  };
361
376
  }
362
377
 
363
- function getPopupRenderFunction(unclusteredLayerId, { popupBackgroundColor: background = COLOR_WHITE, popupBorderColor: borderColor = POPUP_BORDER_COLOR, popupBorderWidth: borderWidth = 2, popupFontColor: fontColor = COLOR_BLACK, popupPadding: padding = 20, popupBorderRadius: radius = 4, popupTitleFontWeight: fontWeight = "bold", }) {
378
+ function getPopupRenderFunction(unclusteredLayerId, { popupBackgroundColor: background = COLOR_WHITE, popupBorderColor: borderColor = POPUP_BORDER_COLOR, popupBorderWidth: borderWidth = 2, popupFontColor: fontColor = COLOR_BLACK, popupPadding: padding = 20, popupBorderRadius: radius = 4, popupTitleFontWeight: fontWeight = 'bold', }) {
364
379
  return (selectedFeature) => {
365
380
  let title, address;
366
381
  // Try to get Title and address from existing feature properties
367
382
  if (strHasLength(selectedFeature.properties.place_name)) {
368
- const placeName = selectedFeature.properties.place_name.split(",");
383
+ const placeName = selectedFeature.properties.place_name.split(',');
369
384
  title = placeName[0];
370
- address = placeName.splice(1, placeName.length).join(",");
385
+ address = placeName.splice(1, placeName.length).join(',');
371
386
  }
372
387
  else if (strHasLength(selectedFeature.properties.title) ||
373
388
  strHasLength(selectedFeature.properties.address)) {
@@ -375,7 +390,7 @@
375
390
  address = selectedFeature.properties.address;
376
391
  }
377
392
  else {
378
- title = "Coordinates";
393
+ title = 'Coordinates';
379
394
  address = selectedFeature.geometry.coordinates;
380
395
  }
381
396
  const titleHtml = `<div class="${unclusteredLayerId}-popup-title" style="font-weight: ${fontWeight};">${title}</div>`;
@@ -386,7 +401,7 @@
386
401
  popupHtml += titleHtml;
387
402
  if (address)
388
403
  popupHtml += addressHtml;
389
- popupHtml += "</div>";
404
+ popupHtml += '</div>';
390
405
  return popupHtml;
391
406
  };
392
407
  }
@@ -402,14 +417,14 @@
402
417
  }
403
418
  return t;
404
419
  };
405
- const HIDE_TIP = "amplify-tip";
420
+ const HIDE_TIP = 'amplify-tip';
406
421
  function drawUnclusteredLayer(sourceName, map, _a) {
407
422
  var { showMarkerPopup = false } = _a, options = __rest$1(_a, ["showMarkerPopup"]);
408
423
  const unclusteredLayerId = `${sourceName}-layer-unclustered-point`;
409
424
  let selectedId = null;
410
425
  function deselectPoint() {
411
426
  if (selectedId !== null) {
412
- map.setLayoutProperty(unclusteredLayerId, "icon-image", "inactive-marker");
427
+ map.setLayoutProperty(unclusteredLayerId, 'icon-image', 'inactive-marker');
413
428
  selectedId = null;
414
429
  }
415
430
  }
@@ -419,11 +434,11 @@
419
434
  addUnclusteredMarkerImages(map, options);
420
435
  const defaultUnclusteredPoint = {
421
436
  id: unclusteredLayerId,
422
- type: "symbol",
437
+ type: 'symbol',
423
438
  source: sourceName,
424
- filter: ["!", ["has", "point_count"]],
439
+ filter: ['!', ['has', 'point_count']],
425
440
  layout: {
426
- "icon-image": "inactive-marker",
441
+ 'icon-image': 'inactive-marker',
427
442
  },
428
443
  };
429
444
  map.addLayer(Object.assign({}, defaultUnclusteredPoint));
@@ -433,28 +448,28 @@
433
448
  if (showMarkerPopup) {
434
449
  const element = document.getElementById(HIDE_TIP);
435
450
  if (!element) {
436
- const style = document.createElement("style");
437
- style.setAttribute("id", HIDE_TIP);
451
+ const style = document.createElement('style');
452
+ style.setAttribute('id', HIDE_TIP);
438
453
  document.head.append(style);
439
- style.textContent = ".mapboxgl-popup-tip { display: none; }";
454
+ style.textContent = '.mapboxgl-popup-tip { display: none; }';
440
455
  }
441
456
  }
442
- map.on("click", function () {
457
+ map.on('click', function () {
443
458
  deselectPoint();
444
459
  });
445
460
  /*
446
461
  * Set active state on markers when clicked
447
462
  */
448
- map.on("click", unclusteredLayerId, function (e) {
449
- if (typeof options.onClick === "function")
463
+ map.on('click', unclusteredLayerId, function (e) {
464
+ if (typeof options.onClick === 'function')
450
465
  options.onClick(e);
451
466
  selectedId = e.features[0].id;
452
- map.setLayoutProperty(unclusteredLayerId, "icon-image", [
453
- "match",
454
- ["id"],
467
+ map.setLayoutProperty(unclusteredLayerId, 'icon-image', [
468
+ 'match',
469
+ ['id'],
455
470
  selectedId,
456
- "active-marker",
457
- "inactive-marker", // default
471
+ 'active-marker',
472
+ 'inactive-marker', // default
458
473
  ]);
459
474
  // If popup option is set show a popup on click
460
475
  if (showMarkerPopup) {
@@ -466,7 +481,7 @@
466
481
  .setHTML(popupRender(selectedFeature))
467
482
  .setOffset(15)
468
483
  .addTo(map);
469
- popup.on("close", function () {
484
+ popup.on('close', function () {
470
485
  if (selectedId === selectedFeature.id)
471
486
  deselectPoint();
472
487
  });
@@ -476,14 +491,14 @@
476
491
  /*
477
492
  * Set cursor style to pointer when mousing over point layer
478
493
  */
479
- map.on("mouseover", unclusteredLayerId, function () {
480
- map.getCanvas().style.cursor = "pointer";
494
+ map.on('mouseover', unclusteredLayerId, function () {
495
+ map.getCanvas().style.cursor = 'pointer';
481
496
  });
482
497
  /*
483
498
  * Reset cursor style when the point layer
484
499
  */
485
- map.on("mouseleave", unclusteredLayerId, () => {
486
- map.getCanvas().style.cursor = "";
500
+ map.on('mouseleave', unclusteredLayerId, () => {
501
+ map.getCanvas().style.cursor = '';
487
502
  });
488
503
  return { unclusteredLayerId };
489
504
  }
@@ -504,8 +519,8 @@
504
519
  strokeColor: selectedBorderColor,
505
520
  lineWidth: selectedBorderWidth,
506
521
  });
507
- map.addImage("inactive-marker", inactiveMarker, { pixelRatio: 2 });
508
- map.addImage("active-marker", activeMarker, { pixelRatio: 2 });
522
+ map.addImage('inactive-marker', inactiveMarker, { pixelRatio: 2 });
523
+ map.addImage('active-marker', activeMarker, { pixelRatio: 2 });
509
524
  }
510
525
 
511
526
  /**
@@ -527,9 +542,9 @@
527
542
  function drawPoints(sourceName, data, map, { showCluster = true, clusterOptions = {}, unclusteredOptions: unclusteredMarkerOptions = {}, autoFit = true, } = {}, mapStyle) {
528
543
  var _a, _b;
529
544
  if (!map ||
530
- typeof map.addSource !== "function" ||
531
- typeof map.addLayer !== "function") {
532
- throw new Error("Please use a maplibre map");
545
+ typeof map.addSource !== 'function' ||
546
+ typeof map.addLayer !== 'function') {
547
+ throw new Error('Please use a maplibre map');
533
548
  }
534
549
  /*
535
550
  * Convert data passed in as coordinates into features
@@ -540,9 +555,9 @@
540
555
  */
541
556
  const sourceId = sourceName;
542
557
  map.addSource(sourceId, {
543
- type: "geojson",
558
+ type: 'geojson',
544
559
  data: {
545
- type: "FeatureCollection",
560
+ type: 'FeatureCollection',
546
561
  features,
547
562
  },
548
563
  cluster: showCluster,
@@ -567,25 +582,25 @@
567
582
  }
568
583
  // utility function for setting layer visibility to none
569
584
  const hide = () => {
570
- map.setLayoutProperty(unclusteredLayerId, "visibility", "none");
585
+ map.setLayoutProperty(unclusteredLayerId, 'visibility', 'none');
571
586
  if (clusterLayerId)
572
- map.setLayoutProperty(clusterLayerId, "visibility", "none");
587
+ map.setLayoutProperty(clusterLayerId, 'visibility', 'none');
573
588
  if (clusterSymbolLayerId)
574
- map.setLayoutProperty(clusterSymbolLayerId, "visibility", "none");
589
+ map.setLayoutProperty(clusterSymbolLayerId, 'visibility', 'none');
575
590
  };
576
591
  // utility function for setting layer visibility to visible
577
592
  const show = () => {
578
- map.setLayoutProperty(unclusteredLayerId, "visibility", "visible");
593
+ map.setLayoutProperty(unclusteredLayerId, 'visibility', 'visible');
579
594
  if (clusterLayerId)
580
- map.setLayoutProperty(clusterLayerId, "visibility", "visible");
595
+ map.setLayoutProperty(clusterLayerId, 'visibility', 'visible');
581
596
  if (clusterSymbolLayerId)
582
- map.setLayoutProperty(clusterSymbolLayerId, "visibility", "visible");
597
+ map.setLayoutProperty(clusterSymbolLayerId, 'visibility', 'visible');
583
598
  };
584
599
  // utility function updating the data source
585
600
  const setData = (data) => {
586
601
  const features = getFeaturesFromData(data);
587
602
  map.getSource(sourceId).setData({
588
- type: "FeatureCollection",
603
+ type: 'FeatureCollection',
589
604
  features,
590
605
  });
591
606
  };
@@ -601,18 +616,18 @@
601
616
  }
602
617
 
603
618
  function createDefaultIcon() {
604
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
605
- const iconPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
606
- const iconCircle = document.createElement("circle");
607
- customIcon.setAttribute("viewBox", "0 0 64 64");
608
- customIcon.setAttribute("width", "32");
609
- customIcon.setAttribute("height", "32");
610
- iconPath.setAttribute("d", LOCATION_MARKER);
611
- iconPath.setAttribute("fill", "#5d8aff");
612
- iconCircle.setAttribute("fill", "white");
613
- iconCircle.setAttribute("cx", "50%");
614
- iconCircle.setAttribute("cy", "50%");
615
- iconCircle.setAttribute("r", "5");
619
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
620
+ const iconPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
621
+ const iconCircle = document.createElement('circle');
622
+ customIcon.setAttribute('viewBox', '0 0 64 64');
623
+ customIcon.setAttribute('width', '32');
624
+ customIcon.setAttribute('height', '32');
625
+ iconPath.setAttribute('d', LOCATION_MARKER);
626
+ iconPath.setAttribute('fill', '#5d8aff');
627
+ iconCircle.setAttribute('fill', 'white');
628
+ iconCircle.setAttribute('cx', '50%');
629
+ iconCircle.setAttribute('cy', '50%');
630
+ iconCircle.setAttribute('r', '5');
616
631
  customIcon.appendChild(iconCircle);
617
632
  customIcon.appendChild(iconPath);
618
633
  return customIcon;
@@ -652,8 +667,8 @@
652
667
  data.forEach((result) => {
653
668
  const { geometry } = result, otherResults = __rest(result, ["geometry"]);
654
669
  features.push({
655
- type: "Feature",
656
- geometry: { type: "Point", coordinates: geometry.point },
670
+ type: 'Feature',
671
+ geometry: { type: 'Point', coordinates: geometry.point },
657
672
  properties: Object.assign({}, otherResults),
658
673
  place_name: otherResults.label,
659
674
  text: otherResults.label,
@@ -663,6 +678,7 @@
663
678
  }
664
679
  }
665
680
  catch (e) {
681
+ // eslint-disable-next-line no-console
666
682
  console.error(`Failed to forwardGeocode with error: ${e}`);
667
683
  }
668
684
  return { features };
@@ -676,8 +692,8 @@
676
692
  if (data && data.geometry) {
677
693
  const { geometry } = data, otherResults = __rest(data, ["geometry"]);
678
694
  features.push({
679
- type: "Feature",
680
- geometry: { type: "Point", coordinates: geometry.point },
695
+ type: 'Feature',
696
+ geometry: { type: 'Point', coordinates: geometry.point },
681
697
  properties: Object.assign({}, otherResults),
682
698
  place_name: otherResults.label,
683
699
  text: otherResults.label,
@@ -686,6 +702,7 @@
686
702
  }
687
703
  }
688
704
  catch (e) {
705
+ // eslint-disable-next-line no-console
689
706
  console.error(`Failed to reverseGeocode with error: ${e}`);
690
707
  }
691
708
  return { features };
@@ -702,6 +719,7 @@
702
719
  suggestions.push(...response);
703
720
  }
704
721
  catch (e) {
722
+ // eslint-disable-next-line no-console
705
723
  console.error(`Failed to get suggestions with error: ${e}`);
706
724
  }
707
725
  return { suggestions };
@@ -713,23 +731,22 @@
713
731
  if (place) {
714
732
  const { geometry } = place, otherResults = __rest(place, ["geometry"]);
715
733
  feature = {
716
- type: "Feature",
717
- geometry: { type: "Point", coordinates: geometry.point },
734
+ type: 'Feature',
735
+ geometry: { type: 'Point', coordinates: geometry.point },
718
736
  properties: Object.assign({}, otherResults),
719
737
  place_name: otherResults.label,
720
738
  text: otherResults.label,
721
739
  center: geometry.point,
722
740
  };
723
741
  }
724
- ;
725
742
  }
726
743
  catch (e) {
744
+ // eslint-disable-next-line no-console
727
745
  console.error(`Failed to get place with error: ${e}`);
728
746
  }
729
747
  return { place: feature };
730
- })
748
+ }),
731
749
  };
732
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
733
750
  function createAmplifyGeocoder(options) {
734
751
  return new MaplibreGeocoder__default["default"](AmplifyGeocoderAPI, Object.assign({ maplibregl: maplibregl__default["default"], showResultMarkers: { element: createDefaultIcon() }, marker: { element: createDefaultIcon() },
735
752
  // autocomplete temporarily disabled by default until CLI is updated
@@ -742,9 +759,9 @@
742
759
  ? data.map((geofence) => geofence.geometry.polygon)
743
760
  : data;
744
761
  return {
745
- type: "Feature",
762
+ type: 'Feature',
746
763
  geometry: {
747
- type: "MultiPolygon",
764
+ type: 'MultiPolygon',
748
765
  coordinates,
749
766
  },
750
767
  properties: {},
@@ -752,9 +769,9 @@
752
769
  };
753
770
  const getGeofenceFeatureFromPolygon = (polygon) => {
754
771
  return {
755
- type: "Feature",
772
+ type: 'Feature',
756
773
  geometry: {
757
- type: "Polygon",
774
+ type: 'Polygon',
758
775
  coordinates: polygon,
759
776
  },
760
777
  properties: {},
@@ -766,13 +783,13 @@
766
783
  const neCoordinate = bounds.getNorthEast().toArray();
767
784
  const center = bounds.getCenter().toArray();
768
785
  const line = helpers.lineString([swCoordinate, center, neCoordinate]);
769
- const distanceInMiles = length__default["default"](line, { units: "miles" });
786
+ const distanceInMiles = length__default["default"](line, { units: 'miles' });
770
787
  // Gets coordinates 1/4 along the line from each coordinate
771
788
  const southWestCoordinate = along__default["default"](line, distanceInMiles / 4, {
772
- units: "miles",
789
+ units: 'miles',
773
790
  }).geometry.coordinates;
774
791
  const northeastCoordinate = along__default["default"](line, distanceInMiles * (3 / 4), {
775
- units: "miles",
792
+ units: 'miles',
776
793
  }).geometry.coordinates;
777
794
  // Creates a polygon from the coordinates found along the line between the bounding coordinates in counter clockwise order starting from northeast most coordinate
778
795
  const polygon = [
@@ -786,9 +803,9 @@
786
803
  ];
787
804
  return {
788
805
  id,
789
- type: "Feature",
806
+ type: 'Feature',
790
807
  geometry: {
791
- type: "Polygon",
808
+ type: 'Polygon',
792
809
  coordinates: polygon,
793
810
  },
794
811
  properties: {},
@@ -796,21 +813,21 @@
796
813
  };
797
814
  const getCircleFeatureFromCoords = (id, center, { bounds, radius }) => {
798
815
  if (!bounds && !radius) {
799
- throw new Error("Circle requires a bounds or a radius");
816
+ throw new Error('Circle requires a bounds or a radius');
800
817
  }
801
818
  validateCoordinates(center);
802
819
  const circleRadius = radius !== null && radius !== void 0 ? radius : getDistanceFromBounds(bounds) / 8;
803
- const circleFeature = circle__default["default"](center, circleRadius, { units: "miles" });
820
+ const circleFeature = circle__default["default"](center, circleRadius, { units: 'miles' });
804
821
  return {
805
822
  id,
806
- type: "Feature",
823
+ type: 'Feature',
807
824
  properties: {
808
825
  isCircle: true,
809
826
  center,
810
827
  radius: circleRadius,
811
828
  },
812
829
  geometry: {
813
- type: "Polygon",
830
+ type: 'Polygon',
814
831
  coordinates: circleFeature.geometry.coordinates,
815
832
  },
816
833
  };
@@ -820,7 +837,7 @@
820
837
  const neCoordinate = bounds.getNorthEast().toArray();
821
838
  const center = bounds.getCenter().toArray();
822
839
  const line = helpers.lineString([swCoordinate, center, neCoordinate]);
823
- return length__default["default"](line, { units: "miles" });
840
+ return length__default["default"](line, { units: 'miles' });
824
841
  };
825
842
  const doesGeofenceExist = (id, loadedGeofences) => {
826
843
  return !!loadedGeofences[id];
@@ -833,7 +850,7 @@
833
850
  };
834
851
  const getDistanceBetweenCoordinates = (startCoord, endCoord) => {
835
852
  const line = helpers.lineString([startCoord, endCoord]);
836
- const distanceInMiles = length__default["default"](line, { units: "miles" });
853
+ const distanceInMiles = length__default["default"](line, { units: 'miles' });
837
854
  return distanceInMiles;
838
855
  };
839
856
 
@@ -846,12 +863,12 @@
846
863
  function drawGeofences(sourceName, data, map, options = {}) {
847
864
  var _a, _b, _c, _d, _e, _f, _g, _h;
848
865
  if (!map ||
849
- typeof map.addSource !== "function" ||
850
- typeof map.addLayer !== "function") {
851
- throw new Error("Please use a maplibre map");
866
+ typeof map.addSource !== 'function' ||
867
+ typeof map.addLayer !== 'function') {
868
+ throw new Error('Please use a maplibre map');
852
869
  }
853
870
  if (data.length > 0 && !isGeofenceArray(data) && !isPolygonArray(data)) {
854
- throw new Error("Please pass in an array of Geofences or an array of Polygons");
871
+ throw new Error('Please pass in an array of Geofences or an array of Polygons');
855
872
  }
856
873
  /*
857
874
  * Data source for features
@@ -859,57 +876,57 @@
859
876
  */
860
877
  const sourceId = `${sourceName}`;
861
878
  map.addSource(sourceId, {
862
- type: "geojson",
879
+ type: 'geojson',
863
880
  data: getGeofenceFeatureArray(data),
864
881
  generateId: true,
865
882
  });
866
- const initialVisiblity = ((_a = options.visible) !== null && _a !== void 0 ? _a : true) ? "visible" : "none";
883
+ const initialVisiblity = ((_a = options.visible) !== null && _a !== void 0 ? _a : true) ? 'visible' : 'none';
867
884
  /*
868
885
  * Draw ui layers for source data
869
886
  */
870
887
  const fillLayerId = `${sourceName}-fill-layer`;
871
888
  map.addLayer({
872
889
  id: fillLayerId,
873
- type: "fill",
890
+ type: 'fill',
874
891
  source: sourceId,
875
892
  layout: {
876
893
  visibility: initialVisiblity,
877
894
  },
878
895
  paint: {
879
- "fill-color": (_b = options.fillColor) !== null && _b !== void 0 ? _b : COLOR_BLACK,
880
- "fill-opacity": (_c = options.fillOpacity) !== null && _c !== void 0 ? _c : FILL_OPACITY,
896
+ 'fill-color': (_b = options.fillColor) !== null && _b !== void 0 ? _b : COLOR_BLACK,
897
+ 'fill-opacity': (_c = options.fillOpacity) !== null && _c !== void 0 ? _c : FILL_OPACITY,
881
898
  },
882
899
  });
883
900
  // Add a black outline around the polygon.
884
901
  const outlineLayerId = `${sourceName}-outline-layer`;
885
902
  map.addLayer({
886
903
  id: outlineLayerId,
887
- type: "line",
904
+ type: 'line',
888
905
  source: sourceId,
889
906
  layout: {
890
907
  visibility: initialVisiblity,
891
908
  },
892
909
  paint: {
893
- "line-color": (_d = options.borderColor) !== null && _d !== void 0 ? _d : COLOR_BLACK,
894
- "line-opacity": (_e = options.borderOpacity) !== null && _e !== void 0 ? _e : BORDER_OPACITY,
895
- "line-width": (_f = options.borderWidth) !== null && _f !== void 0 ? _f : BORDER_WIDTH,
896
- "line-offset": (_g = options.borderOffset) !== null && _g !== void 0 ? _g : (((_h = options.borderWidth) !== null && _h !== void 0 ? _h : BORDER_WIDTH) / 2) * -1,
910
+ 'line-color': (_d = options.borderColor) !== null && _d !== void 0 ? _d : COLOR_BLACK,
911
+ 'line-opacity': (_e = options.borderOpacity) !== null && _e !== void 0 ? _e : BORDER_OPACITY,
912
+ 'line-width': (_f = options.borderWidth) !== null && _f !== void 0 ? _f : BORDER_WIDTH,
913
+ 'line-offset': (_g = options.borderOffset) !== null && _g !== void 0 ? _g : (((_h = options.borderWidth) !== null && _h !== void 0 ? _h : BORDER_WIDTH) / 2) * -1,
897
914
  },
898
915
  });
899
916
  // utility function for setting layer visibility to none
900
917
  const hide = () => {
901
- map.setLayoutProperty(fillLayerId, "visibility", "none");
902
- map.setLayoutProperty(outlineLayerId, "visibility", "none");
918
+ map.setLayoutProperty(fillLayerId, 'visibility', 'none');
919
+ map.setLayoutProperty(outlineLayerId, 'visibility', 'none');
903
920
  };
904
921
  // utility function for setting layer visibility to visible
905
922
  const show = () => {
906
- map.setLayoutProperty(fillLayerId, "visibility", "visible");
907
- map.setLayoutProperty(outlineLayerId, "visibility", "visible");
923
+ map.setLayoutProperty(fillLayerId, 'visibility', 'visible');
924
+ map.setLayoutProperty(outlineLayerId, 'visibility', 'visible');
908
925
  };
909
926
  // utility function for checking layer visibility
910
927
  const isVisible = () => {
911
- const visibility = map.getLayoutProperty(fillLayerId, "visibility");
912
- return visibility === "visible";
928
+ const visibility = map.getLayoutProperty(fillLayerId, 'visibility');
929
+ return visibility === 'visible';
913
930
  };
914
931
  // utility function for setting layer visibility to visible
915
932
  const setData = (data) => {
@@ -926,55 +943,55 @@
926
943
  };
927
944
  }
928
945
 
929
- const EDIT_ICON_PATH = "M0.5 12.375V15.5H3.625L12.8417 6.28333L9.71667 3.15833L0.5 12.375ZM2.93333 13.8333H2.16667V13.0667L9.71667 5.51667L10.4833 6.28333L2.93333 13.8333ZM15.2583 2.69167L13.3083 0.741667C13.1417 0.575 12.9333 0.5 12.7167 0.5C12.5 0.5 12.2917 0.583333 12.1333 0.741667L10.6083 2.26667L13.7333 5.39167L15.2583 3.86667C15.5833 3.54167 15.5833 3.01667 15.2583 2.69167Z";
946
+ const EDIT_ICON_PATH = 'M0.5 12.375V15.5H3.625L12.8417 6.28333L9.71667 3.15833L0.5 12.375ZM2.93333 13.8333H2.16667V13.0667L9.71667 5.51667L10.4833 6.28333L2.93333 13.8333ZM15.2583 2.69167L13.3083 0.741667C13.1417 0.575 12.9333 0.5 12.7167 0.5C12.5 0.5 12.2917 0.583333 12.1333 0.741667L10.6083 2.26667L13.7333 5.39167L15.2583 3.86667C15.5833 3.54167 15.5833 3.01667 15.2583 2.69167Z';
930
947
  function createEditIcon() {
931
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
932
- const iconPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
933
- customIcon.setAttribute("viewBox", "0 0 16 16");
934
- customIcon.setAttribute("width", "16");
935
- customIcon.setAttribute("height", "16");
936
- customIcon.setAttribute("fill", "none");
937
- iconPath.setAttribute("d", EDIT_ICON_PATH);
938
- iconPath.setAttribute("fill", "white");
948
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
949
+ const iconPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
950
+ customIcon.setAttribute('viewBox', '0 0 16 16');
951
+ customIcon.setAttribute('width', '16');
952
+ customIcon.setAttribute('height', '16');
953
+ customIcon.setAttribute('fill', 'none');
954
+ iconPath.setAttribute('d', EDIT_ICON_PATH);
955
+ iconPath.setAttribute('fill', 'white');
939
956
  customIcon.appendChild(iconPath);
940
957
  return customIcon;
941
958
  }
942
- const TRASH_ICON_PATH = "M9.33317 5.5V13.8333H2.6665V5.5H9.33317ZM8.08317 0.5H3.9165L3.08317 1.33333H0.166504V3H11.8332V1.33333H8.9165L8.08317 0.5ZM10.9998 3.83333H0.999837V13.8333C0.999837 14.75 1.74984 15.5 2.6665 15.5H9.33317C10.2498 15.5 10.9998 14.75 10.9998 13.8333V3.83333Z";
959
+ const TRASH_ICON_PATH = 'M9.33317 5.5V13.8333H2.6665V5.5H9.33317ZM8.08317 0.5H3.9165L3.08317 1.33333H0.166504V3H11.8332V1.33333H8.9165L8.08317 0.5ZM10.9998 3.83333H0.999837V13.8333C0.999837 14.75 1.74984 15.5 2.6665 15.5H9.33317C10.2498 15.5 10.9998 14.75 10.9998 13.8333V3.83333Z';
943
960
  function createTrashIcon() {
944
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
945
- const iconPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
946
- customIcon.setAttribute("viewBox", "0 0 12 16");
947
- customIcon.setAttribute("width", "12");
948
- customIcon.setAttribute("height", "16");
949
- customIcon.setAttribute("fill", "none");
950
- iconPath.setAttribute("d", TRASH_ICON_PATH);
951
- iconPath.setAttribute("fill", "white");
961
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
962
+ const iconPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
963
+ customIcon.setAttribute('viewBox', '0 0 12 16');
964
+ customIcon.setAttribute('width', '12');
965
+ customIcon.setAttribute('height', '16');
966
+ customIcon.setAttribute('fill', 'none');
967
+ iconPath.setAttribute('d', TRASH_ICON_PATH);
968
+ iconPath.setAttribute('fill', 'white');
952
969
  customIcon.appendChild(iconPath);
953
970
  return customIcon;
954
971
  }
955
972
  function createPopupStep1Icon() {
956
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
957
- customIcon.setAttribute("viewBox", "0 0 38 38");
958
- customIcon.setAttribute("width", "38");
959
- customIcon.setAttribute("height", "38");
960
- customIcon.setAttribute("fill", "none");
961
- const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
962
- circle.setAttribute("cx", "19");
963
- circle.setAttribute("cy", "18");
964
- circle.setAttribute("r", "8");
965
- circle.setAttribute("fill", "#FF9900");
966
- const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path");
967
- path1.setAttribute("d", "M19 0L23.3302 7.5H14.6699L19 0Z");
968
- path1.setAttribute("fill", "#003560");
969
- const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path");
970
- path2.setAttribute("d", "M19 36.5L14.6698 29H23.3301L19 36.5Z");
971
- path2.setAttribute("fill", "#003560");
972
- const path3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
973
- path3.setAttribute("d", "M0 18.33L7.5 13.9999L7.5 22.6602L0 18.33Z");
974
- path3.setAttribute("fill", "#003560");
975
- const path4 = document.createElementNS("http://www.w3.org/2000/svg", "path");
976
- path4.setAttribute("d", "M37.5 18.3301L30 22.6603V14L37.5 18.3301Z");
977
- path4.setAttribute("fill", "#003560");
973
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
974
+ customIcon.setAttribute('viewBox', '0 0 38 38');
975
+ customIcon.setAttribute('width', '38');
976
+ customIcon.setAttribute('height', '38');
977
+ customIcon.setAttribute('fill', 'none');
978
+ const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
979
+ circle.setAttribute('cx', '19');
980
+ circle.setAttribute('cy', '18');
981
+ circle.setAttribute('r', '8');
982
+ circle.setAttribute('fill', '#FF9900');
983
+ const path1 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
984
+ path1.setAttribute('d', 'M19 0L23.3302 7.5H14.6699L19 0Z');
985
+ path1.setAttribute('fill', '#003560');
986
+ const path2 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
987
+ path2.setAttribute('d', 'M19 36.5L14.6698 29H23.3301L19 36.5Z');
988
+ path2.setAttribute('fill', '#003560');
989
+ const path3 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
990
+ path3.setAttribute('d', 'M0 18.33L7.5 13.9999L7.5 22.6602L0 18.33Z');
991
+ path3.setAttribute('fill', '#003560');
992
+ const path4 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
993
+ path4.setAttribute('d', 'M37.5 18.3301L30 22.6603V14L37.5 18.3301Z');
994
+ path4.setAttribute('fill', '#003560');
978
995
  customIcon.appendChild(circle);
979
996
  customIcon.appendChild(path1);
980
997
  customIcon.appendChild(path2);
@@ -983,107 +1000,107 @@
983
1000
  return customIcon;
984
1001
  }
985
1002
  function createPopupStep2Icon() {
986
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
987
- customIcon.setAttribute("viewBox", "0 0 42 27");
988
- customIcon.setAttribute("width", "42");
989
- customIcon.setAttribute("height", "27");
990
- customIcon.setAttribute("fill", "none");
991
- const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
992
- line.setAttribute("y1", "8");
993
- line.setAttribute("x2", "42");
994
- line.setAttribute("y2", "8");
995
- line.setAttribute("stroke", "black");
996
- line.setAttribute("stroke-width", "2");
997
- const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
998
- circle.setAttribute("cx", "21");
999
- circle.setAttribute("cy", "8");
1000
- circle.setAttribute("r", "8");
1001
- circle.setAttribute("fill", "#FF9900");
1002
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
1003
- path.setAttribute("d", "M21 6.17822V22.488L24.6951 19.4356L27.172 26.1782L29.0399 25.3582L26.6035 18.57L31.4762 17.9322L21 6.17822Z");
1004
- path.setAttribute("fill", "#003560");
1003
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1004
+ customIcon.setAttribute('viewBox', '0 0 42 27');
1005
+ customIcon.setAttribute('width', '42');
1006
+ customIcon.setAttribute('height', '27');
1007
+ customIcon.setAttribute('fill', 'none');
1008
+ const line = document.createElementNS('http://www.w3.org/2000/svg', 'line');
1009
+ line.setAttribute('y1', '8');
1010
+ line.setAttribute('x2', '42');
1011
+ line.setAttribute('y2', '8');
1012
+ line.setAttribute('stroke', 'black');
1013
+ line.setAttribute('stroke-width', '2');
1014
+ const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
1015
+ circle.setAttribute('cx', '21');
1016
+ circle.setAttribute('cy', '8');
1017
+ circle.setAttribute('r', '8');
1018
+ circle.setAttribute('fill', '#FF9900');
1019
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1020
+ path.setAttribute('d', 'M21 6.17822V22.488L24.6951 19.4356L27.172 26.1782L29.0399 25.3582L26.6035 18.57L31.4762 17.9322L21 6.17822Z');
1021
+ path.setAttribute('fill', '#003560');
1005
1022
  customIcon.appendChild(line);
1006
1023
  customIcon.appendChild(circle);
1007
1024
  customIcon.appendChild(path);
1008
1025
  return customIcon;
1009
1026
  }
1010
1027
  function createPopupStep3Icon() {
1011
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1012
- customIcon.setAttribute("viewBox", "0 0 32 32");
1013
- customIcon.setAttribute("width", "32");
1014
- customIcon.setAttribute("height", "32");
1015
- customIcon.setAttribute("fill", "none");
1016
- const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
1017
- rect.setAttribute("y", "1");
1018
- rect.setAttribute("x", "1");
1019
- rect.setAttribute("width", "30");
1020
- rect.setAttribute("height", "30");
1021
- rect.setAttribute("fill", "#2196F3");
1022
- rect.setAttribute("fill-opacity", "0.4");
1023
- rect.setAttribute("stroke", "#003560");
1024
- rect.setAttribute("stroke-width", "2");
1025
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
1026
- path.setAttribute("d", "M11 6V22.3098L14.6951 19.2574L17.172 26L19.0399 25.18L16.6035 18.3918L21.4762 17.754L11 6Z");
1027
- path.setAttribute("fill", "#003560");
1028
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1029
+ customIcon.setAttribute('viewBox', '0 0 32 32');
1030
+ customIcon.setAttribute('width', '32');
1031
+ customIcon.setAttribute('height', '32');
1032
+ customIcon.setAttribute('fill', 'none');
1033
+ const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
1034
+ rect.setAttribute('y', '1');
1035
+ rect.setAttribute('x', '1');
1036
+ rect.setAttribute('width', '30');
1037
+ rect.setAttribute('height', '30');
1038
+ rect.setAttribute('fill', '#2196F3');
1039
+ rect.setAttribute('fill-opacity', '0.4');
1040
+ rect.setAttribute('stroke', '#003560');
1041
+ rect.setAttribute('stroke-width', '2');
1042
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1043
+ path.setAttribute('d', 'M11 6V22.3098L14.6951 19.2574L17.172 26L19.0399 25.18L16.6035 18.3918L21.4762 17.754L11 6Z');
1044
+ path.setAttribute('fill', '#003560');
1028
1045
  customIcon.appendChild(rect);
1029
1046
  customIcon.appendChild(path);
1030
1047
  return customIcon;
1031
1048
  }
1032
1049
  function createPopupStep4Icon() {
1033
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1034
- customIcon.setAttribute("viewBox", "0 0 64 20");
1035
- customIcon.setAttribute("width", "64");
1036
- customIcon.setAttribute("height", "20");
1037
- customIcon.setAttribute("fill", "none");
1038
- const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
1039
- rect.setAttribute("y", "0.5");
1040
- rect.setAttribute("x", "0.5");
1041
- rect.setAttribute("width", "63");
1042
- rect.setAttribute("height", "19");
1043
- rect.setAttribute("rx", "3.5");
1044
- rect.setAttribute("stroke", "#014478");
1045
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
1046
- path.setAttribute("d", "M14.4148 15C17.517 15 19.3118 13.076 19.3118 9.89418C19.3118 6.72727 17.517 4.81818 14.5192 4.81818H11.1186V15H14.4148ZM12.6548 13.6577V6.16051H14.4247C16.652 6.16051 17.8004 7.4929 17.8004 9.89418C17.8004 12.3054 16.652 13.6577 14.3303 13.6577H12.6548ZM24.394 15.1541C26.0595 15.1541 27.2377 14.3338 27.5758 13.0909L26.1689 12.8374C25.9004 13.5582 25.2541 13.9261 24.4089 13.9261C23.1362 13.9261 22.2811 13.1009 22.2413 11.6293H27.6703V11.1023C27.6703 8.34304 26.0197 7.2642 24.2896 7.2642C22.1618 7.2642 20.7598 8.88494 20.7598 11.2315C20.7598 13.603 22.1419 15.1541 24.394 15.1541ZM22.2463 10.5156C22.3059 9.43182 23.0914 8.49219 24.2995 8.49219C25.4529 8.49219 26.2086 9.3473 26.2136 10.5156H22.2463ZM30.8061 4.81818H29.3196V15H30.8061V4.81818ZM36.0971 15.1541C37.7626 15.1541 38.9409 14.3338 39.2789 13.0909L37.872 12.8374C37.6035 13.5582 36.9572 13.9261 36.112 13.9261C34.8393 13.9261 33.9842 13.1009 33.9444 11.6293H39.3734V11.1023C39.3734 8.34304 37.7228 7.2642 35.9927 7.2642C33.8649 7.2642 32.4629 8.88494 32.4629 11.2315C32.4629 13.603 33.845 15.1541 36.0971 15.1541ZM33.9494 10.5156C34.0091 9.43182 34.7946 8.49219 36.0027 8.49219C37.1561 8.49219 37.9118 9.3473 37.9167 10.5156H33.9494ZM44.5874 7.36364H43.0213V5.53409H41.5348V7.36364H40.4162V8.55682H41.5348V13.0661C41.5298 14.4531 42.5888 15.1243 43.7621 15.0994C44.2344 15.0945 44.5526 15.005 44.7266 14.9403L44.4581 13.7124C44.3587 13.7322 44.1747 13.777 43.9361 13.777C43.4538 13.777 43.0213 13.6179 43.0213 12.7578V8.55682H44.5874V7.36364ZM49.4409 15.1541C51.1064 15.1541 52.2846 14.3338 52.6227 13.0909L51.2157 12.8374C50.9473 13.5582 50.301 13.9261 49.4558 13.9261C48.1831 13.9261 47.3279 13.1009 47.2882 11.6293H52.7172V11.1023C52.7172 8.34304 51.0666 7.2642 49.3365 7.2642C47.2086 7.2642 45.8066 8.88494 45.8066 11.2315C45.8066 13.603 47.1887 15.1541 49.4409 15.1541ZM47.2931 10.5156C47.3528 9.43182 48.1383 8.49219 49.3464 8.49219C50.4998 8.49219 51.2555 9.3473 51.2605 10.5156H47.2931Z");
1047
- path.setAttribute("fill", "black");
1050
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1051
+ customIcon.setAttribute('viewBox', '0 0 64 20');
1052
+ customIcon.setAttribute('width', '64');
1053
+ customIcon.setAttribute('height', '20');
1054
+ customIcon.setAttribute('fill', 'none');
1055
+ const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
1056
+ rect.setAttribute('y', '0.5');
1057
+ rect.setAttribute('x', '0.5');
1058
+ rect.setAttribute('width', '63');
1059
+ rect.setAttribute('height', '19');
1060
+ rect.setAttribute('rx', '3.5');
1061
+ rect.setAttribute('stroke', '#014478');
1062
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1063
+ path.setAttribute('d', 'M14.4148 15C17.517 15 19.3118 13.076 19.3118 9.89418C19.3118 6.72727 17.517 4.81818 14.5192 4.81818H11.1186V15H14.4148ZM12.6548 13.6577V6.16051H14.4247C16.652 6.16051 17.8004 7.4929 17.8004 9.89418C17.8004 12.3054 16.652 13.6577 14.3303 13.6577H12.6548ZM24.394 15.1541C26.0595 15.1541 27.2377 14.3338 27.5758 13.0909L26.1689 12.8374C25.9004 13.5582 25.2541 13.9261 24.4089 13.9261C23.1362 13.9261 22.2811 13.1009 22.2413 11.6293H27.6703V11.1023C27.6703 8.34304 26.0197 7.2642 24.2896 7.2642C22.1618 7.2642 20.7598 8.88494 20.7598 11.2315C20.7598 13.603 22.1419 15.1541 24.394 15.1541ZM22.2463 10.5156C22.3059 9.43182 23.0914 8.49219 24.2995 8.49219C25.4529 8.49219 26.2086 9.3473 26.2136 10.5156H22.2463ZM30.8061 4.81818H29.3196V15H30.8061V4.81818ZM36.0971 15.1541C37.7626 15.1541 38.9409 14.3338 39.2789 13.0909L37.872 12.8374C37.6035 13.5582 36.9572 13.9261 36.112 13.9261C34.8393 13.9261 33.9842 13.1009 33.9444 11.6293H39.3734V11.1023C39.3734 8.34304 37.7228 7.2642 35.9927 7.2642C33.8649 7.2642 32.4629 8.88494 32.4629 11.2315C32.4629 13.603 33.845 15.1541 36.0971 15.1541ZM33.9494 10.5156C34.0091 9.43182 34.7946 8.49219 36.0027 8.49219C37.1561 8.49219 37.9118 9.3473 37.9167 10.5156H33.9494ZM44.5874 7.36364H43.0213V5.53409H41.5348V7.36364H40.4162V8.55682H41.5348V13.0661C41.5298 14.4531 42.5888 15.1243 43.7621 15.0994C44.2344 15.0945 44.5526 15.005 44.7266 14.9403L44.4581 13.7124C44.3587 13.7322 44.1747 13.777 43.9361 13.777C43.4538 13.777 43.0213 13.6179 43.0213 12.7578V8.55682H44.5874V7.36364ZM49.4409 15.1541C51.1064 15.1541 52.2846 14.3338 52.6227 13.0909L51.2157 12.8374C50.9473 13.5582 50.301 13.9261 49.4558 13.9261C48.1831 13.9261 47.3279 13.1009 47.2882 11.6293H52.7172V11.1023C52.7172 8.34304 51.0666 7.2642 49.3365 7.2642C47.2086 7.2642 45.8066 8.88494 45.8066 11.2315C45.8066 13.603 47.1887 15.1541 49.4409 15.1541ZM47.2931 10.5156C47.3528 9.43182 48.1383 8.49219 49.3464 8.49219C50.4998 8.49219 51.2555 9.3473 51.2605 10.5156H47.2931Z');
1064
+ path.setAttribute('fill', 'black');
1048
1065
  customIcon.appendChild(rect);
1049
1066
  customIcon.appendChild(path);
1050
1067
  return customIcon;
1051
1068
  }
1052
1069
  function createDeleteSuccessIcon() {
1053
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1054
- customIcon.setAttribute("viewBox", "0 0 12 12");
1055
- customIcon.setAttribute("width", "12");
1056
- customIcon.setAttribute("height", "12");
1057
- customIcon.setAttribute("fill", "none");
1058
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
1059
- path.setAttribute("d", "M6 0C2.688 0 0 2.688 0 6C0 9.312 2.688 12 6 12C9.312 12 12 9.312 12 6C12 2.688 9.312 0 6 0ZM6 10.8C3.354 10.8 1.2 8.646 1.2 6C1.2 3.354 3.354 1.2 6 1.2C8.646 1.2 10.8 3.354 10.8 6C10.8 8.646 8.646 10.8 6 10.8ZM8.754 3.348L4.8 7.302L3.246 5.754L2.4 6.6L4.8 9L9.6 4.2L8.754 3.348Z");
1060
- path.setAttribute("fill", "white");
1070
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1071
+ customIcon.setAttribute('viewBox', '0 0 12 12');
1072
+ customIcon.setAttribute('width', '12');
1073
+ customIcon.setAttribute('height', '12');
1074
+ customIcon.setAttribute('fill', 'none');
1075
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1076
+ path.setAttribute('d', 'M6 0C2.688 0 0 2.688 0 6C0 9.312 2.688 12 6 12C9.312 12 12 9.312 12 6C12 2.688 9.312 0 6 0ZM6 10.8C3.354 10.8 1.2 8.646 1.2 6C1.2 3.354 3.354 1.2 6 1.2C8.646 1.2 10.8 3.354 10.8 6C10.8 8.646 8.646 10.8 6 10.8ZM8.754 3.348L4.8 7.302L3.246 5.754L2.4 6.6L4.8 9L9.6 4.2L8.754 3.348Z');
1077
+ path.setAttribute('fill', 'white');
1061
1078
  customIcon.appendChild(path);
1062
1079
  return customIcon;
1063
1080
  }
1064
1081
  function createCloseIcon() {
1065
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1066
- customIcon.setAttribute("viewBox", "0 0 12 12");
1067
- customIcon.setAttribute("width", "12");
1068
- customIcon.setAttribute("height", "12");
1069
- customIcon.setAttribute("fill", "none");
1070
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
1071
- path.setAttribute("d", "M10.773 2.28762L9.71231 1.22696L6 4.93927L2.28769 1.22696L1.22703 2.28762L4.93934 5.99993L1.22703 9.71224L2.28769 10.7729L6 7.06059L9.71231 10.7729L10.773 9.71224L7.06066 5.99993L10.773 2.28762Z");
1072
- path.setAttribute("fill", "white");
1073
- path.setAttribute("fill-rule", "evenodd");
1074
- path.setAttribute("clip-rule", "evenodd");
1082
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1083
+ customIcon.setAttribute('viewBox', '0 0 12 12');
1084
+ customIcon.setAttribute('width', '12');
1085
+ customIcon.setAttribute('height', '12');
1086
+ customIcon.setAttribute('fill', 'none');
1087
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1088
+ path.setAttribute('d', 'M10.773 2.28762L9.71231 1.22696L6 4.93927L2.28769 1.22696L1.22703 2.28762L4.93934 5.99993L1.22703 9.71224L2.28769 10.7729L6 7.06059L9.71231 10.7729L10.773 9.71224L7.06066 5.99993L10.773 2.28762Z');
1089
+ path.setAttribute('fill', 'white');
1090
+ path.setAttribute('fill-rule', 'evenodd');
1091
+ path.setAttribute('clip-rule', 'evenodd');
1075
1092
  customIcon.appendChild(path);
1076
1093
  return customIcon;
1077
1094
  }
1078
1095
  function createErrorIcon() {
1079
- const customIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1080
- customIcon.setAttribute("viewBox", "0 0 12 10");
1081
- customIcon.setAttribute("width", "12");
1082
- customIcon.setAttribute("height", "10");
1083
- customIcon.setAttribute("fill", "none");
1084
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
1085
- path.setAttribute("d", "M0 10H11.5789L5.78947 0L0 10ZM6.31579 8.42105H5.26316V7.36842H6.31579V8.42105ZM6.31579 6.31579H5.26316V4.21053H6.31579V6.31579Z");
1086
- path.setAttribute("fill", "#FF5050");
1096
+ const customIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1097
+ customIcon.setAttribute('viewBox', '0 0 12 10');
1098
+ customIcon.setAttribute('width', '12');
1099
+ customIcon.setAttribute('height', '10');
1100
+ customIcon.setAttribute('fill', 'none');
1101
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1102
+ path.setAttribute('d', 'M0 10H11.5789L5.78947 0L0 10ZM6.31579 8.42105H5.26316V7.36842H6.31579V8.42105ZM6.31579 6.31579H5.26316V4.21053H6.31579V6.31579Z');
1103
+ path.setAttribute('fill', '#FF5050');
1087
1104
  customIcon.appendChild(path);
1088
1105
  return customIcon;
1089
1106
  }
@@ -1116,7 +1133,7 @@
1116
1133
  if (map._controlPositions[positionName]) {
1117
1134
  return;
1118
1135
  }
1119
- const positionContainer = document.createElement("div");
1136
+ const positionContainer = document.createElement('div');
1120
1137
  positionContainer.className = `maplibregl-ctrl-${positionName}`;
1121
1138
  map._controlContainer.appendChild(positionContainer);
1122
1139
  map._controlPositions[positionName] = positionContainer;
@@ -1125,16 +1142,16 @@
1125
1142
  * Create Geofence Controls
1126
1143
  *************************************************************/
1127
1144
  function createGeofenceCreateContainer(isCircle) {
1128
- const container = createElement("div", "geofence-ctrl-create-prompt-container", geofenceControlContainer);
1129
- _createContainer = createElement("div", "geofence-ctrl-create-prompt", container);
1145
+ const container = createElement('div', 'geofence-ctrl-create-prompt-container', geofenceControlContainer);
1146
+ _createContainer = createElement('div', 'geofence-ctrl-create-prompt', container);
1130
1147
  if (isCircle) {
1131
1148
  /* Create buttons to switch between different modes */
1132
- const buttonContainer = createElement("div", "geofence-ctrl-create-prompt-buttons", _createContainer);
1133
- const circleModeButton = createElement("div", "geofence-ctrl-create-prompt-button-circle geofence-ctrl-create-prompt-button", buttonContainer);
1134
- circleModeButton.addEventListener("click", () => {
1149
+ const buttonContainer = createElement('div', 'geofence-ctrl-create-prompt-buttons', _createContainer);
1150
+ const circleModeButton = createElement('div', 'geofence-ctrl-create-prompt-button-circle geofence-ctrl-create-prompt-button', buttonContainer);
1151
+ circleModeButton.addEventListener('click', () => {
1135
1152
  // Change button selected style
1136
- circleModeButton.classList.add("geofence-ctrl-create-prompt-selected");
1137
- polygonModeButton.classList.remove("geofence-ctrl-create-prompt-selected");
1153
+ circleModeButton.classList.add('geofence-ctrl-create-prompt-selected');
1154
+ polygonModeButton.classList.remove('geofence-ctrl-create-prompt-selected');
1138
1155
  // Switch info box mode
1139
1156
  if (_polygonModeContainer) {
1140
1157
  removeElement(_polygonModeContainer);
@@ -1142,15 +1159,15 @@
1142
1159
  }
1143
1160
  if (!_circleModeContainer)
1144
1161
  createCircleModeCreateContainer(_createContainer);
1145
- geofenceControl.changeMode("draw_circle");
1162
+ geofenceControl.changeMode('draw_circle');
1146
1163
  });
1147
- circleModeButton.innerHTML = "Circle";
1148
- const polygonModeButton = createElement("div", "geofence-ctrl-create-prompt-button-polygon geofence-ctrl-create-prompt-button", buttonContainer);
1149
- polygonModeButton.addEventListener("click", () => {
1150
- geofenceControl.changeMode("draw_polygon");
1164
+ circleModeButton.innerHTML = 'Circle';
1165
+ const polygonModeButton = createElement('div', 'geofence-ctrl-create-prompt-button-polygon geofence-ctrl-create-prompt-button', buttonContainer);
1166
+ polygonModeButton.addEventListener('click', () => {
1167
+ geofenceControl.changeMode('draw_polygon');
1151
1168
  // Change button selected style
1152
- polygonModeButton.classList.add("geofence-ctrl-create-prompt-selected");
1153
- circleModeButton.classList.remove("geofence-ctrl-create-prompt-selected");
1169
+ polygonModeButton.classList.add('geofence-ctrl-create-prompt-selected');
1170
+ circleModeButton.classList.remove('geofence-ctrl-create-prompt-selected');
1154
1171
  // Switch info box mode
1155
1172
  if (_circleModeContainer) {
1156
1173
  removeElement(_circleModeContainer);
@@ -1159,8 +1176,8 @@
1159
1176
  if (!_polygonModeContainer)
1160
1177
  createPolygonModeCreateContainer(_createContainer);
1161
1178
  });
1162
- polygonModeButton.innerHTML = "Custom";
1163
- circleModeButton.classList.add("geofence-ctrl-create-prompt-selected");
1179
+ polygonModeButton.innerHTML = 'Custom';
1180
+ circleModeButton.classList.add('geofence-ctrl-create-prompt-selected');
1164
1181
  createCircleModeCreateContainer(_createContainer);
1165
1182
  }
1166
1183
  else {
@@ -1168,45 +1185,45 @@
1168
1185
  }
1169
1186
  }
1170
1187
  function createCircleModeCreateContainer(container) {
1171
- _circleModeContainer = createElement("div", "geofence-ctrl-create-circle-mode-container", container);
1172
- const radiusTitle = createElement("div", "geofence-ctrl-create-circle-mode-title", _circleModeContainer);
1173
- radiusTitle.innerHTML = "Radius";
1174
- _geofenceCreateRadiusInput = createElement("input", "geofence-ctrl-create-circle-mode-input", _circleModeContainer);
1175
- _geofenceCreateRadiusInput.addEventListener("keydown", debounce.debounce(geofenceControl.updateInputRadius, 200));
1188
+ _circleModeContainer = createElement('div', 'geofence-ctrl-create-circle-mode-container', container);
1189
+ const radiusTitle = createElement('div', 'geofence-ctrl-create-circle-mode-title', _circleModeContainer);
1190
+ radiusTitle.innerHTML = 'Radius';
1191
+ _geofenceCreateRadiusInput = createElement('input', 'geofence-ctrl-create-circle-mode-input', _circleModeContainer);
1192
+ _geofenceCreateRadiusInput.addEventListener('keydown', debounce.debounce(geofenceControl.updateInputRadius, 200));
1176
1193
  }
1177
1194
  function createPolygonModeCreateContainer(container) {
1178
- _polygonModeContainer = createElement("div", "geofence-ctrl-create-polygon-mode-container", container);
1179
- const moreInfoContainer = createElement("div", "geofence-ctrl-create-polygon-mode-info-container", _polygonModeContainer);
1180
- const moreInfoIcon = createElement("div", "geofence-ctrl-create-polygon-mode-icon", moreInfoContainer);
1181
- const letterI = createElement("div", "geofence-ctrl-create-polygon-mode-info-icon", moreInfoIcon);
1182
- letterI.innerHTML = "i";
1183
- const moreInfo = createElement("div", "geofence-ctrl-create-polygon-mode-title", moreInfoContainer);
1184
- moreInfo.innerHTML = "How it works?";
1185
- const resetButton = createElement("div", "geofence-ctrl-create-polygon-mode-reset-button geofence-ctrl-button", _polygonModeContainer);
1186
- resetButton.innerHTML = "Reset";
1187
- resetButton.addEventListener("click", () => {
1195
+ _polygonModeContainer = createElement('div', 'geofence-ctrl-create-polygon-mode-container', container);
1196
+ const moreInfoContainer = createElement('div', 'geofence-ctrl-create-polygon-mode-info-container', _polygonModeContainer);
1197
+ const moreInfoIcon = createElement('div', 'geofence-ctrl-create-polygon-mode-icon', moreInfoContainer);
1198
+ const letterI = createElement('div', 'geofence-ctrl-create-polygon-mode-info-icon', moreInfoIcon);
1199
+ letterI.innerHTML = 'i';
1200
+ const moreInfo = createElement('div', 'geofence-ctrl-create-polygon-mode-title', moreInfoContainer);
1201
+ moreInfo.innerHTML = 'How it works?';
1202
+ const resetButton = createElement('div', 'geofence-ctrl-create-polygon-mode-reset-button geofence-ctrl-button', _polygonModeContainer);
1203
+ resetButton.innerHTML = 'Reset';
1204
+ resetButton.addEventListener('click', () => {
1188
1205
  geofenceControl.resetGeofence();
1189
1206
  });
1190
1207
  // Add popup onClick
1191
1208
  const popup = createPolygonModeInfoPopup(moreInfoIcon);
1192
- moreInfoContainer.addEventListener("click", () => {
1193
- popup.classList.toggle("show");
1209
+ moreInfoContainer.addEventListener('click', () => {
1210
+ popup.classList.toggle('show');
1194
1211
  });
1195
1212
  }
1196
1213
  function createPolygonModeInfoPopup(container) {
1197
- const popupContainer = createElement("div", "geofence-ctrl-create-polygon-mode-popup-container", container);
1198
- const popup = createElement("div", "geofence-ctrl-create-polygon-mode-popup", popupContainer);
1199
- createPopupStep(popup, "Move dots to desired position", createPopupStep1Icon());
1200
- createPopupStep(popup, "Click on a border to create a dot", createPopupStep2Icon());
1201
- createPopupStep(popup, "Click into shape to move", createPopupStep3Icon());
1202
- createPopupStep(popup, "Press delete to remove a dot", createPopupStep4Icon());
1214
+ const popupContainer = createElement('div', 'geofence-ctrl-create-polygon-mode-popup-container', container);
1215
+ const popup = createElement('div', 'geofence-ctrl-create-polygon-mode-popup', popupContainer);
1216
+ createPopupStep(popup, 'Move dots to desired position', createPopupStep1Icon());
1217
+ createPopupStep(popup, 'Click on a border to create a dot', createPopupStep2Icon());
1218
+ createPopupStep(popup, 'Click into shape to move', createPopupStep3Icon());
1219
+ createPopupStep(popup, 'Press delete to remove a dot', createPopupStep4Icon());
1203
1220
  return popup;
1204
1221
  }
1205
1222
  function createPopupStep(container, text, image) {
1206
- const popupStep = createElement("div", "geofence-ctrl-create-polygon-mode-popup-step", container);
1207
- const popupStepImage = createElement("div", "geofence-ctrl-create-polygon-mode-popup-step-image", popupStep);
1223
+ const popupStep = createElement('div', 'geofence-ctrl-create-polygon-mode-popup-step', container);
1224
+ const popupStepImage = createElement('div', 'geofence-ctrl-create-polygon-mode-popup-step-image', popupStep);
1208
1225
  popupStepImage.appendChild(image);
1209
- const popupStepText = createElement("div", "geofence-ctrl-create-polygon-mode-popup-step-text", popupStep);
1226
+ const popupStepText = createElement('div', 'geofence-ctrl-create-polygon-mode-popup-step-text', popupStep);
1210
1227
  popupStepText.innerHTML = text;
1211
1228
  }
1212
1229
  function removeGeofenceCreateContainer() {
@@ -1219,10 +1236,10 @@
1219
1236
  * Geofence List
1220
1237
  *************************************************************/
1221
1238
  function createGeofenceListContainer() {
1222
- const geofenceListContainer = createElement("div", "geofence-ctrl-list-container", geofenceControlContainer);
1239
+ const geofenceListContainer = createElement('div', 'geofence-ctrl-list-container', geofenceControlContainer);
1223
1240
  createGeofenceListHeader(geofenceListContainer);
1224
- _geofenceList = createElement("div", "geofence-ctrl-list", geofenceListContainer);
1225
- _geofenceList.addEventListener("scroll", () => {
1241
+ _geofenceList = createElement('div', 'geofence-ctrl-list', geofenceListContainer);
1242
+ _geofenceList.addEventListener('scroll', () => {
1226
1243
  const { scrollHeight, scrollTop, clientHeight } = _geofenceList;
1227
1244
  if (scrollTop + clientHeight >= scrollHeight - 20) {
1228
1245
  geofenceControl.loadMoreGeofences();
@@ -1230,43 +1247,43 @@
1230
1247
  });
1231
1248
  }
1232
1249
  function createGeofenceListHeader(geofenceListContainer) {
1233
- const header = createElement("div", "geofence-ctrl-list-header", geofenceListContainer);
1234
- _geofenceTitle = createElement("div", "geofence-ctrl-list-header-title", header);
1235
- _geofenceTitle.innerHTML = "Geofences (0)";
1236
- _checkBoxAllAndCreateContainer = createElement("div", "geofence-ctrl-list-header-checkbox-create-container", header);
1250
+ const header = createElement('div', 'geofence-ctrl-list-header', geofenceListContainer);
1251
+ _geofenceTitle = createElement('div', 'geofence-ctrl-list-header-title', header);
1252
+ _geofenceTitle.innerHTML = 'Geofences (0)';
1253
+ _checkBoxAllAndCreateContainer = createElement('div', 'geofence-ctrl-list-header-checkbox-create-container', header);
1237
1254
  createCheckboxAllContainer(_checkBoxAllAndCreateContainer);
1238
1255
  }
1239
1256
  function createCheckboxAllContainer(geofenceListContainer) {
1240
- _checkBoxAllContainer = createElement("div", "geofence-ctrl-list-checkbox-all-container", geofenceListContainer);
1241
- _checkboxAll = createElement("input", "geofence-ctrl-list-checkbox-all", _checkBoxAllContainer);
1242
- _checkboxAll.type = "checkbox";
1243
- _checkboxAll.addEventListener("click", function () {
1257
+ _checkBoxAllContainer = createElement('div', 'geofence-ctrl-list-checkbox-all-container', geofenceListContainer);
1258
+ _checkboxAll = createElement('input', 'geofence-ctrl-list-checkbox-all', _checkBoxAllContainer);
1259
+ _checkboxAll.type = 'checkbox';
1260
+ _checkboxAll.addEventListener('click', function () {
1244
1261
  if (_checkboxAll.checked) {
1245
1262
  geofenceControl.displayAllGeofences();
1246
- checkboxAllText.innerHTML = "Deselect All";
1263
+ checkboxAllText.innerHTML = 'Deselect All';
1247
1264
  }
1248
1265
  else {
1249
1266
  geofenceControl.hideAllGeofences();
1250
- checkboxAllText.innerHTML = "Select All";
1267
+ checkboxAllText.innerHTML = 'Select All';
1251
1268
  }
1252
1269
  });
1253
- const checkboxAllText = createElement("div", "geofence-ctrl-list-checkbox-all-title", _checkBoxAllContainer);
1254
- checkboxAllText.innerHTML = "Select all";
1255
- _addGeofencebutton = createElement("div", "geofence-ctrl-list-header-add-button", _checkBoxAllContainer);
1256
- _addGeofencebutton.innerHTML = "+ Add";
1257
- _addGeofencebutton.addEventListener("click", () => {
1270
+ const checkboxAllText = createElement('div', 'geofence-ctrl-list-checkbox-all-title', _checkBoxAllContainer);
1271
+ checkboxAllText.innerHTML = 'Select all';
1272
+ _addGeofencebutton = createElement('div', 'geofence-ctrl-list-header-add-button', _checkBoxAllContainer);
1273
+ _addGeofencebutton.innerHTML = '+ Add';
1274
+ _addGeofencebutton.addEventListener('click', () => {
1258
1275
  createAddGeofenceContainer();
1259
1276
  });
1260
1277
  }
1261
1278
  function renderListItem(geofence) {
1262
- const container = createElement("li", "geofence-ctrl-list-item-container", _geofenceList);
1279
+ const container = createElement('li', 'geofence-ctrl-list-item-container', _geofenceList);
1263
1280
  container.id = `list-item-${geofence.geofenceId}`;
1264
- const listItem = createElement("li", "geofence-ctrl-list-item", container);
1265
- const leftContainer = createElement("div", "geofence-ctrl-list-item-left-container", listItem);
1266
- const checkbox = createElement("input", "geofence-ctrl-list-item-checkbox", leftContainer);
1281
+ const listItem = createElement('li', 'geofence-ctrl-list-item', container);
1282
+ const leftContainer = createElement('div', 'geofence-ctrl-list-item-left-container', listItem);
1283
+ const checkbox = createElement('input', 'geofence-ctrl-list-item-checkbox', leftContainer);
1267
1284
  checkbox.id = `list-item-checkbox-${geofence.geofenceId}`;
1268
- checkbox.type = "checkbox";
1269
- checkbox.addEventListener("click", function () {
1285
+ checkbox.type = 'checkbox';
1286
+ checkbox.addEventListener('click', function () {
1270
1287
  if (checkbox.checked) {
1271
1288
  geofenceControl.displayGeofence(geofence.geofenceId);
1272
1289
  geofenceControl.fitGeofence(geofence.geofenceId);
@@ -1275,48 +1292,48 @@
1275
1292
  geofenceControl.hideGeofence(geofence.geofenceId);
1276
1293
  }
1277
1294
  });
1278
- const rightContainer = createElement("div", "geofence-ctrl-list-item-right-container", listItem);
1279
- const geofenceTitleContainer = createElement("div", "geofence-ctrl-list-item-title-container", rightContainer);
1280
- geofenceTitleContainer.addEventListener("mouseover", function () {
1295
+ const rightContainer = createElement('div', 'geofence-ctrl-list-item-right-container', listItem);
1296
+ const geofenceTitleContainer = createElement('div', 'geofence-ctrl-list-item-title-container', rightContainer);
1297
+ geofenceTitleContainer.addEventListener('mouseover', function () {
1281
1298
  geofenceControl.displayHighlightedGeofence(geofence.geofenceId);
1282
1299
  });
1283
- geofenceTitleContainer.addEventListener("mouseout", function () {
1300
+ geofenceTitleContainer.addEventListener('mouseout', function () {
1284
1301
  geofenceControl.hideHighlightedGeofence();
1285
1302
  });
1286
- const geofenceTitle = createElement("div", "geofence-ctrl-list-item-title", geofenceTitleContainer);
1303
+ const geofenceTitle = createElement('div', 'geofence-ctrl-list-item-title', geofenceTitleContainer);
1287
1304
  geofenceTitle.innerHTML = geofence.geofenceId;
1288
- const editButton = createElement("div", "geofence-ctrl-edit-button", geofenceTitleContainer);
1289
- editButton.addEventListener("click", function () {
1305
+ const editButton = createElement('div', 'geofence-ctrl-edit-button', geofenceTitleContainer);
1306
+ editButton.addEventListener('click', function () {
1290
1307
  geofenceControl.editGeofence(geofence.geofenceId);
1291
1308
  createEditControls(listItem, rightContainer, leftContainer, geofence.geofenceId);
1292
- listItem.classList.remove("geofence-ctrl-list-item");
1293
- listItem.classList.add("geofence-ctrl-list-selected-item");
1309
+ listItem.classList.remove('geofence-ctrl-list-item');
1310
+ listItem.classList.add('geofence-ctrl-list-selected-item');
1294
1311
  });
1295
1312
  editButton.appendChild(createEditIcon());
1296
1313
  }
1297
1314
  function createEditControls(item, rightContainer, leftContainer, id) {
1298
- const editContainer = createElement("div", "geofence-ctrl-list-item-controls", rightContainer);
1315
+ const editContainer = createElement('div', 'geofence-ctrl-list-item-controls', rightContainer);
1299
1316
  const deleteButton = renderDeleteButton(leftContainer, id);
1300
1317
  const removeEditContainer = () => {
1301
- item.classList.remove("geofence-ctrl-list-selected-item");
1302
- item.classList.add("geofence-ctrl-list-item");
1318
+ item.classList.remove('geofence-ctrl-list-selected-item');
1319
+ item.classList.add('geofence-ctrl-list-item');
1303
1320
  removeElement(editContainer);
1304
1321
  removeElement(deleteButton);
1305
1322
  };
1306
- const cancelButton = createElement("div", "geofence-ctrl-cancel-button", editContainer);
1307
- cancelButton.classList.add("geofence-ctrl-button");
1308
- cancelButton.innerHTML = "Cancel";
1309
- cancelButton.addEventListener("click", () => {
1323
+ const cancelButton = createElement('div', 'geofence-ctrl-cancel-button', editContainer);
1324
+ cancelButton.classList.add('geofence-ctrl-button');
1325
+ cancelButton.innerHTML = 'Cancel';
1326
+ cancelButton.addEventListener('click', () => {
1310
1327
  geofenceControl.setEditingModeEnabled(false);
1311
1328
  removeEditContainer();
1312
1329
  });
1313
- const saveGeofenceButton = createElement("div", "geofence-ctrl-save-button geofence-ctrl-button", editContainer);
1314
- saveGeofenceButton.addEventListener("click", () => __awaiter$1(this, void 0, void 0, function* () {
1330
+ const saveGeofenceButton = createElement('div', 'geofence-ctrl-save-button geofence-ctrl-button', editContainer);
1331
+ saveGeofenceButton.addEventListener('click', () => __awaiter$1(this, void 0, void 0, function* () {
1315
1332
  yield geofenceControl.saveGeofence();
1316
1333
  removeEditContainer();
1317
1334
  }));
1318
- saveGeofenceButton.title = "Save";
1319
- saveGeofenceButton.innerHTML = "Save";
1335
+ saveGeofenceButton.title = 'Save';
1336
+ saveGeofenceButton.innerHTML = 'Save';
1320
1337
  }
1321
1338
  /************************************************************
1322
1339
  * Add Geofence Controls
@@ -1334,20 +1351,20 @@
1334
1351
  }
1335
1352
  function createAddGeofenceContainer() {
1336
1353
  hideCheckboxAllContainer();
1337
- _addGeofenceContainer = createElement("div", "geofence-ctrl-add-geofence-container", _checkBoxAllAndCreateContainer);
1338
- const addGeofencePrompt = createElement("div", "geofence-ctrl-add-geofence", _addGeofenceContainer);
1339
- const nameInput = createElement("input", "geofence-ctrl-add-geofence-input", addGeofencePrompt);
1340
- nameInput.placeholder = "Enter name";
1341
- const buttonContainer = createElement("div", "geofence-ctrl-add-geofence-buttons", addGeofencePrompt);
1342
- const cancelButton = createElement("div", "geofence-ctrl-add-geofence-cancel-button geofence-ctrl-button ", buttonContainer);
1343
- cancelButton.innerHTML = "Cancel";
1344
- cancelButton.addEventListener("click", () => {
1354
+ _addGeofenceContainer = createElement('div', 'geofence-ctrl-add-geofence-container', _checkBoxAllAndCreateContainer);
1355
+ const addGeofencePrompt = createElement('div', 'geofence-ctrl-add-geofence', _addGeofenceContainer);
1356
+ const nameInput = createElement('input', 'geofence-ctrl-add-geofence-input', addGeofencePrompt);
1357
+ nameInput.placeholder = 'Enter name';
1358
+ const buttonContainer = createElement('div', 'geofence-ctrl-add-geofence-buttons', addGeofencePrompt);
1359
+ const cancelButton = createElement('div', 'geofence-ctrl-add-geofence-cancel-button geofence-ctrl-button ', buttonContainer);
1360
+ cancelButton.innerHTML = 'Cancel';
1361
+ cancelButton.addEventListener('click', () => {
1345
1362
  removeAddGeofenceContainer();
1346
1363
  geofenceControl.setEditingModeEnabled(false);
1347
1364
  });
1348
- const saveButton = createElement("div", "geofence-ctrl-button geofence-ctrl-save-button", buttonContainer);
1349
- saveButton.innerHTML = "Save";
1350
- saveButton.addEventListener("click", function () {
1365
+ const saveButton = createElement('div', 'geofence-ctrl-button geofence-ctrl-save-button', buttonContainer);
1366
+ saveButton.innerHTML = 'Save';
1367
+ saveButton.addEventListener('click', function () {
1351
1368
  return __awaiter$1(this, void 0, void 0, function* () {
1352
1369
  clearAddGeofenceError();
1353
1370
  const output = yield geofenceControl.createGeofence(escape(nameInput.value));
@@ -1361,41 +1378,41 @@
1361
1378
  if (_errorDiv) {
1362
1379
  return;
1363
1380
  }
1364
- _errorDiv = createElement("div", "geofence-ctrl-add-geofence-error", _addGeofenceContainer);
1365
- const errorIconContainer = createElement("div", "geofence-ctrl-add-geofence-error-icon", _errorDiv);
1381
+ _errorDiv = createElement('div', 'geofence-ctrl-add-geofence-error', _addGeofenceContainer);
1382
+ const errorIconContainer = createElement('div', 'geofence-ctrl-add-geofence-error-icon', _errorDiv);
1366
1383
  errorIconContainer.appendChild(createErrorIcon());
1367
- const errorText = createElement("div", "geofence-ctrl-add-geofence-error-text", _errorDiv);
1384
+ const errorText = createElement('div', 'geofence-ctrl-add-geofence-error-text', _errorDiv);
1368
1385
  errorText.innerHTML = error;
1369
1386
  }
1370
1387
  /************************************************************
1371
1388
  * Delete Controls
1372
1389
  *************************************************************/
1373
1390
  function renderDeleteButton(container, id) {
1374
- const deleteButton = createElement("div", "geofence-ctrl-delete-button", container);
1375
- deleteButton.classList.add("geofence-ctrl-button");
1376
- deleteButton.addEventListener("click", function () {
1391
+ const deleteButton = createElement('div', 'geofence-ctrl-delete-button', container);
1392
+ deleteButton.classList.add('geofence-ctrl-button');
1393
+ deleteButton.addEventListener('click', function () {
1377
1394
  createConfirmDeleteContainer(id);
1378
1395
  });
1379
1396
  deleteButton.appendChild(createTrashIcon());
1380
1397
  return deleteButton;
1381
1398
  }
1382
1399
  function createConfirmDeleteContainer(geofenceId) {
1383
- _deleteGeofenceContainer = createElement("div", "geofence-ctrl-delete-prompt-container", geofenceControlContainer);
1384
- const deleteGeofencePrompt = createElement("div", "geofence-ctrl-delete-prompt", _deleteGeofenceContainer);
1385
- const title = createElement("div", "geofence-ctrl-delete-geofence-title", deleteGeofencePrompt);
1400
+ _deleteGeofenceContainer = createElement('div', 'geofence-ctrl-delete-prompt-container', geofenceControlContainer);
1401
+ const deleteGeofencePrompt = createElement('div', 'geofence-ctrl-delete-prompt', _deleteGeofenceContainer);
1402
+ const title = createElement('div', 'geofence-ctrl-delete-geofence-title', deleteGeofencePrompt);
1386
1403
  title.innerHTML = `Are you sure you want to delete <strong>${geofenceId}</strong>?`;
1387
1404
  createDeleteButtonsContainer(deleteGeofencePrompt, geofenceId);
1388
1405
  }
1389
1406
  function createDeleteButtonsContainer(container, geofenceId) {
1390
- const deleteButtonsContainer = createElement("div", "geofence-ctrl-delete-geofence-buttons", container);
1391
- const cancelButton = createElement("div", "geofence-ctrl-delete-geofence-cancel-button", deleteButtonsContainer);
1392
- cancelButton.innerHTML = "Cancel";
1393
- cancelButton.addEventListener("click", () => {
1407
+ const deleteButtonsContainer = createElement('div', 'geofence-ctrl-delete-geofence-buttons', container);
1408
+ const cancelButton = createElement('div', 'geofence-ctrl-delete-geofence-cancel-button', deleteButtonsContainer);
1409
+ cancelButton.innerHTML = 'Cancel';
1410
+ cancelButton.addEventListener('click', () => {
1394
1411
  removeElement(_deleteGeofenceContainer);
1395
1412
  });
1396
- const confirmDeleteButton = createElement("div", "geofence-ctrl-delete-geofence-confirm-button", deleteButtonsContainer);
1397
- confirmDeleteButton.innerHTML = "Delete";
1398
- confirmDeleteButton.addEventListener("click", function () {
1413
+ const confirmDeleteButton = createElement('div', 'geofence-ctrl-delete-geofence-confirm-button', deleteButtonsContainer);
1414
+ confirmDeleteButton.innerHTML = 'Delete';
1415
+ confirmDeleteButton.addEventListener('click', function () {
1399
1416
  return __awaiter$1(this, void 0, void 0, function* () {
1400
1417
  const id = yield geofenceControl.deleteGeofence(geofenceId);
1401
1418
  if (id) {
@@ -1407,19 +1424,19 @@
1407
1424
  });
1408
1425
  }
1409
1426
  function createDeleteResultContainer(success) {
1410
- _deletePopdownContainer = createElement("div", "geofence-ctrl-delete-popdown-container", geofenceControlContainer);
1411
- const deletePopdown = createElement("div", "geofence-ctrl-delete-popdown", _deletePopdownContainer);
1412
- const deletePopdownCloseButton = createElement("div", "geofence-ctrl-delete-popdown-close-button", _deletePopdownContainer);
1427
+ _deletePopdownContainer = createElement('div', 'geofence-ctrl-delete-popdown-container', geofenceControlContainer);
1428
+ const deletePopdown = createElement('div', 'geofence-ctrl-delete-popdown', _deletePopdownContainer);
1429
+ const deletePopdownCloseButton = createElement('div', 'geofence-ctrl-delete-popdown-close-button', _deletePopdownContainer);
1413
1430
  deletePopdownCloseButton.appendChild(createCloseIcon());
1414
- deletePopdownCloseButton.addEventListener("click", () => {
1431
+ deletePopdownCloseButton.addEventListener('click', () => {
1415
1432
  removeElement(_deletePopdownContainer);
1416
1433
  });
1417
- const deleteSuccessIcon = createElement("div", "geofence-ctrl-delete-popdown-icon", deletePopdown);
1434
+ const deleteSuccessIcon = createElement('div', 'geofence-ctrl-delete-popdown-icon', deletePopdown);
1418
1435
  deleteSuccessIcon.appendChild(createDeleteSuccessIcon());
1419
- const deletePopdownText = createElement("div", "geofence-ctrl-delete-popdown-text", deletePopdown);
1436
+ const deletePopdownText = createElement('div', 'geofence-ctrl-delete-popdown-text', deletePopdown);
1420
1437
  deletePopdownText.innerHTML = success
1421
- ? "Geofence was deleted successfully"
1422
- : "Geofence failed to delete";
1438
+ ? 'Geofence was deleted successfully'
1439
+ : 'Geofence failed to delete';
1423
1440
  }
1424
1441
  /************************************************************
1425
1442
  * Utility Methods
@@ -1436,17 +1453,17 @@
1436
1453
  function setGeofenceListEnabled(enabled) {
1437
1454
  _checkboxAll.disabled = !enabled;
1438
1455
  enabled
1439
- ? _addGeofencebutton.classList.remove("geofence-ctrl-noHover")
1440
- : _addGeofencebutton.classList.add("geofence-ctrl-noHover");
1441
- const inputs = document.getElementsByClassName("geofence-ctrl-list-item-checkbox");
1456
+ ? _addGeofencebutton.classList.remove('geofence-ctrl-noHover')
1457
+ : _addGeofencebutton.classList.add('geofence-ctrl-noHover');
1458
+ const inputs = document.getElementsByClassName('geofence-ctrl-list-item-checkbox');
1442
1459
  for (let i = 0; i < inputs.length; i++) {
1443
1460
  inputs.item(i).disabled = !enabled;
1444
1461
  }
1445
- const items = document.getElementsByClassName("geofence-ctrl-list-item-container");
1462
+ const items = document.getElementsByClassName('geofence-ctrl-list-item-container');
1446
1463
  for (let i = 0; i < items.length; i++) {
1447
1464
  enabled
1448
- ? items.item(i).classList.remove("geofence-ctrl-noHover")
1449
- : items.item(i).classList.add("geofence-ctrl-noHover");
1465
+ ? items.item(i).classList.remove('geofence-ctrl-noHover')
1466
+ : items.item(i).classList.add('geofence-ctrl-noHover');
1450
1467
  }
1451
1468
  }
1452
1469
  function getCheckboxAllValue() {
@@ -1460,10 +1477,10 @@
1460
1477
  _geofenceCreateRadiusInput.value = `${radius}`;
1461
1478
  }
1462
1479
  function hideCheckboxAllContainer() {
1463
- _checkBoxAllContainer.style.display = "none";
1480
+ _checkBoxAllContainer.style.display = 'none';
1464
1481
  }
1465
1482
  function showCheckboxAllContainer() {
1466
- _checkBoxAllContainer.style.display = "flex";
1483
+ _checkBoxAllContainer.style.display = 'flex';
1467
1484
  }
1468
1485
  return {
1469
1486
  registerControlPosition,
@@ -1488,7 +1505,7 @@
1488
1505
  constructor(map, ui) {
1489
1506
  this._mapBoxDraw = new MapboxDraw__default["default"]({
1490
1507
  displayControlsDefault: false,
1491
- defaultMode: "simple_select",
1508
+ defaultMode: 'simple_select',
1492
1509
  userProperties: true,
1493
1510
  controls: {
1494
1511
  trash: true,
@@ -1498,54 +1515,54 @@
1498
1515
  // ACTIVE (being drawn)
1499
1516
  // polygon fill
1500
1517
  {
1501
- id: "gl-draw-polygon-fill",
1502
- type: "fill",
1503
- filter: ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
1518
+ id: 'gl-draw-polygon-fill',
1519
+ type: 'fill',
1520
+ filter: ['all', ['==', '$type', 'Polygon'], ['!=', 'mode', 'static']],
1504
1521
  paint: {
1505
- "fill-color": GEOFENCE_COLOR,
1506
- "fill-outline-color": GEOFENCE_COLOR,
1507
- "fill-opacity": 0.3,
1522
+ 'fill-color': GEOFENCE_COLOR,
1523
+ 'fill-outline-color': GEOFENCE_COLOR,
1524
+ 'fill-opacity': 0.3,
1508
1525
  },
1509
1526
  },
1510
1527
  // polygon mid points
1511
1528
  {
1512
- id: "gl-draw-polygon-midpoint",
1513
- type: "circle",
1514
- filter: ["all", ["==", "$type", "Point"], ["==", "meta", "midpoint"]],
1529
+ id: 'gl-draw-polygon-midpoint',
1530
+ type: 'circle',
1531
+ filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'midpoint']],
1515
1532
  paint: {
1516
- "circle-radius": 5,
1517
- "circle-color": GEOFENCE_VERTEX_COLOR,
1533
+ 'circle-radius': 5,
1534
+ 'circle-color': GEOFENCE_VERTEX_COLOR,
1518
1535
  },
1519
1536
  },
1520
1537
  // polygon border
1521
1538
  {
1522
- id: "gl-draw-polygon-stroke-active",
1523
- type: "line",
1524
- filter: ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
1539
+ id: 'gl-draw-polygon-stroke-active',
1540
+ type: 'line',
1541
+ filter: ['all', ['==', '$type', 'Polygon'], ['!=', 'mode', 'static']],
1525
1542
  layout: {
1526
- "line-cap": "round",
1527
- "line-join": "round",
1543
+ 'line-cap': 'round',
1544
+ 'line-join': 'round',
1528
1545
  },
1529
1546
  paint: {
1530
- "line-color": GEOFENCE_BORDER_COLOR,
1531
- "line-width": 4,
1547
+ 'line-color': GEOFENCE_BORDER_COLOR,
1548
+ 'line-width': 4,
1532
1549
  },
1533
1550
  },
1534
1551
  // vertex circle
1535
1552
  {
1536
- id: "gl-draw-polygon-and-line-vertex-active",
1537
- type: "circle",
1553
+ id: 'gl-draw-polygon-and-line-vertex-active',
1554
+ type: 'circle',
1538
1555
  filter: [
1539
- "all",
1540
- ["==", "meta", "vertex"],
1541
- ["==", "$type", "Point"],
1542
- ["!=", "mode", "static"],
1556
+ 'all',
1557
+ ['==', 'meta', 'vertex'],
1558
+ ['==', '$type', 'Point'],
1559
+ ['!=', 'mode', 'static'],
1543
1560
  ],
1544
1561
  paint: {
1545
- "circle-radius": 8,
1546
- "circle-color": GEOFENCE_VERTEX_COLOR,
1547
- "circle-stroke-color": GEOFENCE_BORDER_COLOR,
1548
- "circle-stroke-width": 1,
1562
+ 'circle-radius': 8,
1563
+ 'circle-color': GEOFENCE_VERTEX_COLOR,
1564
+ 'circle-stroke-color': GEOFENCE_BORDER_COLOR,
1565
+ 'circle-stroke-width': 1,
1549
1566
  },
1550
1567
  },
1551
1568
  ],
@@ -1563,7 +1580,7 @@
1563
1580
  const isCircle = data.properties.isCircle;
1564
1581
  this.enable(isCircle);
1565
1582
  this._mapBoxDraw.add(data);
1566
- this._mapBoxDraw.changeMode("direct_select", {
1583
+ this._mapBoxDraw.changeMode('direct_select', {
1567
1584
  featureId: data.id,
1568
1585
  });
1569
1586
  }
@@ -1580,7 +1597,7 @@
1580
1597
  if (this._map.hasControl(this._mapBoxDraw)) {
1581
1598
  return;
1582
1599
  }
1583
- this._map.addControl(this._mapBoxDraw, "bottom-right");
1600
+ this._map.addControl(this._mapBoxDraw, 'bottom-right');
1584
1601
  this._ui.createGeofenceCreateContainer(isCircle);
1585
1602
  }
1586
1603
  /**
@@ -1644,7 +1661,7 @@
1644
1661
  Public Methods for AmplifyGeofenceControl
1645
1662
  **********************************************************************/
1646
1663
  getDefaultPosition() {
1647
- return "full-screen";
1664
+ return 'full-screen';
1648
1665
  }
1649
1666
  onRemove() {
1650
1667
  this._ui.removeElement(this._container);
@@ -1652,41 +1669,41 @@
1652
1669
  // Reorders MapLibre canvas class names to fix a mapbox draw bug - https://github.com/mapbox/mapbox-gl-draw/pull/1079
1653
1670
  reorderMapLibreClassNames() {
1654
1671
  const mapCanvas = document
1655
- .getElementsByClassName("maplibregl-canvas")
1672
+ .getElementsByClassName('maplibregl-canvas')
1656
1673
  .item(0);
1657
1674
  if (mapCanvas) {
1658
- mapCanvas.className = "mapboxgl-canvas maplibregl-canvas";
1675
+ mapCanvas.className = 'mapboxgl-canvas maplibregl-canvas';
1659
1676
  }
1660
1677
  }
1661
1678
  onAdd(map) {
1662
1679
  this._map = map;
1663
1680
  this.reorderMapLibreClassNames();
1664
- this._container = createElement("div", "geofence-ctrl maplibregl-ctrl");
1681
+ this._container = createElement('div', 'geofence-ctrl maplibregl-ctrl');
1665
1682
  this._ui = AmplifyGeofenceControlUI(this, this._container);
1666
1683
  this._amplifyDraw = new AmplifyMapDraw(map, this._ui);
1667
- this._ui.registerControlPosition(map, "full-screen");
1684
+ this._ui.registerControlPosition(map, 'full-screen');
1668
1685
  this._ui.createGeofenceListContainer();
1669
1686
  // Draw the geofences source to the map so we can update it on geofences load/creation
1670
- this._map.once("load", function () {
1687
+ this._map.once('load', function () {
1671
1688
  // Prevents warnings on multiple re-renders, especially when rendered in react
1672
- if (this._map.getSource("displayedGeofences")) {
1689
+ if (this._map.getSource('displayedGeofences')) {
1673
1690
  return;
1674
1691
  }
1675
- this._drawGeofencesOutput = drawGeofences("displayedGeofences", [], this._map, {
1692
+ this._drawGeofencesOutput = drawGeofences('displayedGeofences', [], this._map, {
1676
1693
  fillColor: GEOFENCE_COLOR,
1677
1694
  borderColor: GEOFENCE_BORDER_COLOR,
1678
1695
  borderOpacity: 1,
1679
1696
  });
1680
- this._highlightedGeofenceOutput = drawGeofences("highlightedGeofence", [], this._map, {
1697
+ this._highlightedGeofenceOutput = drawGeofences('highlightedGeofence', [], this._map, {
1681
1698
  fillColor: GEOFENCE_COLOR,
1682
1699
  borderColor: GEOFENCE_BORDER_COLOR,
1683
1700
  borderOpacity: 1,
1684
1701
  borderWidth: 6,
1685
1702
  });
1686
1703
  this.loadInitialGeofences();
1687
- map.addControl(new maplibregl__default["default"].NavigationControl({ showCompass: false }), "bottom-right");
1704
+ map.addControl(new maplibregl__default["default"].NavigationControl({ showCompass: false }), 'bottom-right');
1688
1705
  }.bind(this));
1689
- this._map.on("draw.update", () => {
1706
+ this._map.on('draw.update', () => {
1690
1707
  const coordinates = this._amplifyDraw._mapBoxDraw.getAll().features[0].geometry.coordinates[0];
1691
1708
  const radius = getDistanceBetweenCoordinates(coordinates[0], coordinates[Math.floor(coordinates.length / 2)]) / 2;
1692
1709
  this._ui.updateGeofenceRadius(radius.toFixed(2));
@@ -1696,15 +1713,15 @@
1696
1713
  createGeofence(geofenceId) {
1697
1714
  return __awaiter(this, void 0, void 0, function* () {
1698
1715
  if (!geofenceId || geofenceId.length === 0) {
1699
- this._ui.createAddGeofencePromptError("Geofence ID is empty.");
1716
+ this._ui.createAddGeofencePromptError('Geofence ID is empty.');
1700
1717
  return;
1701
1718
  }
1702
1719
  if (!isValidGeofenceId(geofenceId)) {
1703
- this._ui.createAddGeofencePromptError("Geofence ID contains special characters.");
1720
+ this._ui.createAddGeofencePromptError('Geofence ID contains special characters.');
1704
1721
  return;
1705
1722
  }
1706
1723
  if (isExistingGeofenceId(geofenceId, this._loadedGeofences)) {
1707
- this._ui.createAddGeofencePromptError("Geofence ID already exists.");
1724
+ this._ui.createAddGeofencePromptError('Geofence ID already exists.');
1708
1725
  return;
1709
1726
  }
1710
1727
  return this.saveGeofence(geofenceId);
@@ -1716,7 +1733,7 @@
1716
1733
  const idToSave = geofenceId || this._editingGeofenceId;
1717
1734
  const response = yield geo.Geo.saveGeofences({
1718
1735
  geofenceId: idToSave,
1719
- geometry: { polygon: feature.geometry["coordinates"] },
1736
+ geometry: { polygon: feature.geometry['coordinates'] },
1720
1737
  });
1721
1738
  if (response.errors[0]) {
1722
1739
  const err = response.errors[0];
@@ -1725,7 +1742,7 @@
1725
1742
  const success = response.successes[0];
1726
1743
  const savedGeofence = {
1727
1744
  geofenceId: success.geofenceId,
1728
- geometry: { polygon: feature.geometry["coordinates"] },
1745
+ geometry: { polygon: feature.geometry['coordinates'] },
1729
1746
  };
1730
1747
  // render geofence to the map and add it to the list
1731
1748
  this._loadGeofence(savedGeofence);
@@ -1828,7 +1845,7 @@
1828
1845
  displayAllGeofences() {
1829
1846
  this._displayedGeofences.push(...Object.values(this._loadedGeofences));
1830
1847
  this._updateDisplayedGeofences();
1831
- const checkboxes = document.getElementsByClassName("geofence-ctrl-list-item-checkbox");
1848
+ const checkboxes = document.getElementsByClassName('geofence-ctrl-list-item-checkbox');
1832
1849
  Array.from(checkboxes).forEach((checkbox) => (checkbox.checked = this._ui.getCheckboxAllValue()));
1833
1850
  this.fitAllGeofences();
1834
1851
  }
@@ -1862,7 +1879,7 @@
1862
1879
  hideAllGeofences() {
1863
1880
  this._displayedGeofences = [];
1864
1881
  this._updateDisplayedGeofences();
1865
- const checkboxes = document.getElementsByClassName("geofence-ctrl-list-item-checkbox");
1882
+ const checkboxes = document.getElementsByClassName('geofence-ctrl-list-item-checkbox');
1866
1883
  Array.from(checkboxes).forEach((checkbox) => (checkbox.checked = this._ui.getCheckboxAllValue()));
1867
1884
  }
1868
1885
  _updateDisplayedGeofences() {
@@ -1872,6 +1889,7 @@
1872
1889
  displayHighlightedGeofence(geofenceId) {
1873
1890
  const geofence = this._loadedGeofences[geofenceId];
1874
1891
  if (!geofence) {
1892
+ // eslint-disable-next-line no-console
1875
1893
  console.warn(`Geofence with id ${geofenceId} does not exist`);
1876
1894
  return;
1877
1895
  }
@@ -1888,7 +1906,7 @@
1888
1906
  changeMode(mode) {
1889
1907
  // erase existing mapbox draw content
1890
1908
  this._amplifyDraw.delete(this._editingGeofenceId);
1891
- if (mode === "draw_circle") {
1909
+ if (mode === 'draw_circle') {
1892
1910
  this._amplifyDraw.drawCircularGeofence(this._editingGeofenceId);
1893
1911
  }
1894
1912
  else {
@@ -1922,8 +1940,8 @@
1922
1940
  this._amplifyDraw.drawCircularGeofence(this._editingGeofenceId, radius);
1923
1941
  }
1924
1942
  addEditableGeofence() {
1925
- this._editingGeofenceId = "tempGeofence";
1926
- this._amplifyDraw.drawCircularGeofence("tempGeofence");
1943
+ this._editingGeofenceId = 'tempGeofence';
1944
+ this._amplifyDraw.drawCircularGeofence('tempGeofence');
1927
1945
  this.setEditingModeEnabled(true);
1928
1946
  }
1929
1947
  }