radar-sdk-js 4.4.0-beta.2 → 4.4.0-beta.4

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.
package/README.md CHANGED
@@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ });
56
56
 
57
57
  Add the following script in your `html` file
58
58
  ```html
59
- <script src="https://js.radar.com/v4.4.0-beta.2/radar.min.js"></script>
59
+ <script src="https://js.radar.com/v4.4.0-beta.4/radar.min.js"></script>
60
60
  ```
61
61
 
62
62
  Then initialize the Radar SDK
@@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then
73
73
  ```html
74
74
  <html>
75
75
  <head>
76
- <link href="https://js.radar.com/v4.4.0-beta.2/radar.css" rel="stylesheet">
77
- <script src="https://js.radar.com/v4.4.0-beta.2/radar.min.js"></script>
76
+ <link href="https://js.radar.com/v4.4.0-beta.4/radar.css" rel="stylesheet">
77
+ <script src="https://js.radar.com/v4.4.0-beta.4/radar.min.js"></script>
78
78
  </head>
79
79
 
80
80
  <body>
@@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis
98
98
  ```html
99
99
  <html>
100
100
  <head>
101
- <link href="https://js.radar.com/v4.4.0-beta.2/radar.css" rel="stylesheet">
102
- <script src="https://js.radar.com/v4.4.0-beta.2/radar.min.js"></script>
101
+ <link href="https://js.radar.com/v4.4.0-beta.4/radar.css" rel="stylesheet">
102
+ <script src="https://js.radar.com/v4.4.0-beta.4/radar.min.js"></script>
103
103
  </head>
104
104
 
105
105
  <body>
@@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper
130
130
  ```html
131
131
  <html>
132
132
  <head>
133
- <link href="https://js.radar.com/v4.4.0-beta.2/radar.css" rel="stylesheet">
134
- <script src="https://js.radar.com/v4.4.0-beta.2/radar.min.js"></script>
133
+ <link href="https://js.radar.com/v4.4.0-beta.4/radar.css" rel="stylesheet">
134
+ <script src="https://js.radar.com/v4.4.0-beta.4/radar.min.js"></script>
135
135
  </head>
136
136
 
137
137
  <body>
package/dist/radar.js CHANGED
@@ -405,7 +405,7 @@ class Navigator {
405
405
  }
406
406
  }
407
407
 
408
- var SDK_VERSION = '4.4.0-beta.2';
408
+ var SDK_VERSION = '4.4.0-beta.4';
409
409
 
410
410
  const inFlightRequests = new Map();
411
411
  class Http {
@@ -1456,6 +1456,12 @@ class RadarMapFeature {
1456
1456
  this._sourceIds = [];
1457
1457
  this._layerIds = [];
1458
1458
  this.id = ((_a = feature.id) !== null && _a !== void 0 ? _a : `feature-${Date.now()}`).toString();
1459
+ // check for duplicate IDs
1460
+ (map.getFeatures() || []).forEach((feature) => {
1461
+ if (feature.id === this.id) {
1462
+ throw new Error(`RadarMapFeature: feature with id ${this.id} already exists.`);
1463
+ }
1464
+ });
1459
1465
  this.geometry = feature.geometry;
1460
1466
  this.properties = feature.properties || {};
1461
1467
  this._feature = feature;
@@ -1554,21 +1560,22 @@ const filterUndefined = (object) => {
1554
1560
  });
1555
1561
  return obj;
1556
1562
  };
1557
- // deep merge nested objects
1558
- // (arrays are concatenated
1563
+ // deep merge nested objects - returns a new object
1564
+ // (arrays are concatenated)
1559
1565
  const mergeDeep = (target, source = {}) => {
1566
+ let output = Object.assign({}, target);
1560
1567
  for (const key in source) {
1561
1568
  if (source[key] instanceof Object && !Array.isArray(source[key]) && key in target) {
1562
- Object.assign(source[key], mergeDeep(target[key], source[key]));
1569
+ output[key] = mergeDeep(target[key], source[key]);
1563
1570
  }
1564
1571
  else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
1565
- target[key] = target[key].concat(source[key]);
1572
+ output[key] = target[key].concat(source[key]);
1566
1573
  }
1567
1574
  else {
1568
- target[key] = source[key];
1575
+ output[key] = source[key];
1569
1576
  }
1570
1577
  }
1571
- return target;
1578
+ return output;
1572
1579
  };
1573
1580
 
1574
1581
  const defaultLineOptions = {
@@ -2095,7 +2102,18 @@ class RadarMarker extends maplibregl.Marker {
2095
2102
  const element = this.getElement();
2096
2103
  if (element) {
2097
2104
  element.addEventListener('click', (e) => {
2098
- e.stopPropagation();
2105
+ e.stopPropagation(); // prevent clicks from propagating to map
2106
+ // since we're stopping the propagation to map,
2107
+ // we need to manually toggle the popup associated with the marker
2108
+ if (this.getPopup()) {
2109
+ // close any other open popups
2110
+ (this._map.getMarkers() || []).forEach((otherMarker) => {
2111
+ if (otherMarker.getPopup().isOpen()) {
2112
+ otherMarker.togglePopup();
2113
+ }
2114
+ });
2115
+ this.togglePopup();
2116
+ }
2099
2117
  this.fire('click', new RadarMarkerMouseEvent('click', this, e));
2100
2118
  });
2101
2119
  }
package/dist/radar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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  {
2
2
  "name": "radar-sdk-js",
3
- "version": "4.4.0-beta.2",
3
+ "version": "4.4.0-beta.4",
4
4
  "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.",
5
5
  "homepage": "https://radar.com",
6
6
  "type": "module",
@@ -26,6 +26,14 @@ abstract class RadarMapFeature {
26
26
 
27
27
  constructor(map: RadarMap, feature: GeoJSON.Feature) {
28
28
  this.id = (feature.id ?? `feature-${Date.now()}`).toString();
29
+
30
+ // check for duplicate IDs
31
+ (map.getFeatures() || []).forEach((feature) => {
32
+ if (feature.id === this.id) {
33
+ throw new Error(`RadarMapFeature: feature with id ${this.id} already exists.`);
34
+ }
35
+ });
36
+
29
37
  this.geometry = feature.geometry;
30
38
  this.properties = feature.properties || {};
31
39
  this._feature = feature;
@@ -160,7 +160,20 @@ class RadarMarker extends maplibregl.Marker {
160
160
  const element = this.getElement();
161
161
  if (element) {
162
162
  element.addEventListener('click', (e) => {
163
- e.stopPropagation();
163
+ e.stopPropagation(); // prevent clicks from propagating to map
164
+
165
+ // since we're stopping the propagation to map,
166
+ // we need to manually toggle the popup associated with the marker
167
+ if (this.getPopup()) {
168
+ // close any other open popups
169
+ (this._map.getMarkers() || []).forEach((otherMarker) => {
170
+ if (otherMarker.getPopup().isOpen()) {
171
+ otherMarker.togglePopup();
172
+ }
173
+ });
174
+ this.togglePopup();
175
+ }
176
+
164
177
  this.fire('click', new RadarMarkerMouseEvent('click', this, e));
165
178
  });
166
179
  }
@@ -11,17 +11,18 @@ export const filterUndefined = (object: any) => {
11
11
  return obj;
12
12
  };
13
13
 
14
- // deep merge nested objects
15
- // (arrays are concatenated
14
+ // deep merge nested objects - returns a new object
15
+ // (arrays are concatenated)
16
16
  export const mergeDeep = (target: any, source: any = {}) => {
17
+ let output = Object.assign({}, target);
17
18
  for (const key in source) {
18
19
  if (source[key] instanceof Object && !Array.isArray(source[key]) && key in target) {
19
- Object.assign(source[key], mergeDeep(target[key], source[key]));
20
+ output[key] = mergeDeep(target[key], source[key]);
20
21
  } else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
21
- target[key] = target[key].concat(source[key]);
22
+ output[key] = target[key].concat(source[key]);
22
23
  } else {
23
- target[key] = source[key];
24
+ output[key] = source[key];
24
25
  }
25
26
  }
26
- return target;
27
+ return output;
27
28
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '4.4.0-beta.2';
1
+ export default '4.4.0-beta.4';