radar-sdk-js 4.1.1 → 4.1.2-beta.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.
- package/README.md +7 -7
- package/dist/radar.js +46 -5
- package/dist/radar.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/ui/autocomplete.d.ts +3 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/types.ts +2 -0
- package/src/ui/autocomplete.ts +30 -2
- package/src/ui/map.ts +22 -3
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ });
|
|
|
57
57
|
|
|
58
58
|
Add the following script in your `html` file
|
|
59
59
|
```html
|
|
60
|
-
<script src="https://js.radar.com/v4.1.
|
|
60
|
+
<script src="https://js.radar.com/v4.1.2-beta.0/radar.min.js"></script>
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
Then initialize the Radar SDK
|
|
@@ -74,8 +74,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then
|
|
|
74
74
|
```html
|
|
75
75
|
<html>
|
|
76
76
|
<head>
|
|
77
|
-
<link href="https://js.radar.com/v4.1.
|
|
78
|
-
<script src="https://js.radar.com/v4.1.
|
|
77
|
+
<link href="https://js.radar.com/v4.1.2-beta.0/radar.css" rel="stylesheet">
|
|
78
|
+
<script src="https://js.radar.com/v4.1.2-beta.0/radar.min.js"></script>
|
|
79
79
|
</head>
|
|
80
80
|
|
|
81
81
|
<body>
|
|
@@ -99,8 +99,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis
|
|
|
99
99
|
```html
|
|
100
100
|
<html>
|
|
101
101
|
<head>
|
|
102
|
-
<link href="https://js.radar.com/v4.1.
|
|
103
|
-
<script src="https://js.radar.com/v4.1.
|
|
102
|
+
<link href="https://js.radar.com/v4.1.2-beta.0/radar.css" rel="stylesheet">
|
|
103
|
+
<script src="https://js.radar.com/v4.1.2-beta.0/radar.min.js"></script>
|
|
104
104
|
</head>
|
|
105
105
|
|
|
106
106
|
<body>
|
|
@@ -131,8 +131,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper
|
|
|
131
131
|
```html
|
|
132
132
|
<html>
|
|
133
133
|
<head>
|
|
134
|
-
<link href="https://js.radar.com/v4.1.
|
|
135
|
-
<script src="https://js.radar.com/v4.1.
|
|
134
|
+
<link href="https://js.radar.com/v4.1.2-beta.0/radar.css" rel="stylesheet">
|
|
135
|
+
<script src="https://js.radar.com/v4.1.2-beta.0/radar.min.js"></script>
|
|
136
136
|
</head>
|
|
137
137
|
|
|
138
138
|
<body>
|
package/dist/radar.js
CHANGED
|
@@ -565,7 +565,7 @@ var Navigator = /** @class */ (function () {
|
|
|
565
565
|
return Navigator;
|
|
566
566
|
}());
|
|
567
567
|
|
|
568
|
-
var SDK_VERSION = '4.1.
|
|
568
|
+
var SDK_VERSION = '4.1.2-beta.0';
|
|
569
569
|
|
|
570
570
|
var Http = /** @class */ (function () {
|
|
571
571
|
function Http() {
|
|
@@ -1581,6 +1581,11 @@ var VerifyAPI = /** @class */ (function () {
|
|
|
1581
1581
|
}());
|
|
1582
1582
|
|
|
1583
1583
|
var DEFAULT_STYLE = 'radar-default-v1';
|
|
1584
|
+
var RADAR_STYLES = [
|
|
1585
|
+
'radar-default-v1',
|
|
1586
|
+
'radar-light-v1',
|
|
1587
|
+
'radar-dark-v1',
|
|
1588
|
+
];
|
|
1584
1589
|
var RADAR_LOGO_URL = 'https://api.radar.io/maps/static/images/logo.svg';
|
|
1585
1590
|
var defaultMaplibreOptions = {
|
|
1586
1591
|
minZoom: 1,
|
|
@@ -1599,7 +1604,8 @@ var createStyleURL = function (options, style) {
|
|
|
1599
1604
|
};
|
|
1600
1605
|
// use formatted style URL if using one of Radar's out-of-the-box styles
|
|
1601
1606
|
var getStyle = function (options, mapOptions) {
|
|
1602
|
-
|
|
1607
|
+
var style = mapOptions.style;
|
|
1608
|
+
if (!style || (typeof style === 'string' && RADAR_STYLES.includes(style))) {
|
|
1603
1609
|
return createStyleURL(options, mapOptions.style);
|
|
1604
1610
|
}
|
|
1605
1611
|
return mapOptions.style;
|
|
@@ -1617,10 +1623,20 @@ var MapUI = /** @class */ (function () {
|
|
|
1617
1623
|
}
|
|
1618
1624
|
// configure maplibre options
|
|
1619
1625
|
var style = getStyle(options, mapOptions);
|
|
1620
|
-
var maplibreOptions = Object.assign({}, defaultMaplibreOptions, { style: style }
|
|
1626
|
+
var maplibreOptions = Object.assign({}, defaultMaplibreOptions, mapOptions, { style: style });
|
|
1621
1627
|
Logger.debug("initialize map with options: ".concat(JSON.stringify(maplibreOptions)));
|
|
1622
1628
|
// set container
|
|
1623
1629
|
maplibreOptions.container = mapOptions.container;
|
|
1630
|
+
// custom request handler for Radar styles
|
|
1631
|
+
maplibreOptions.transformRequest = function (url, resourceType) {
|
|
1632
|
+
if (resourceType === 'Style' && RADAR_STYLES.includes(url)) {
|
|
1633
|
+
var radarStyleURL = createStyleURL(options, url);
|
|
1634
|
+
return { url: radarStyleURL };
|
|
1635
|
+
}
|
|
1636
|
+
else {
|
|
1637
|
+
return { url: url };
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1624
1640
|
// create map
|
|
1625
1641
|
var map = new maplibregl.Map(maplibreOptions);
|
|
1626
1642
|
var container = map.getContainer();
|
|
@@ -1743,6 +1759,14 @@ var AutocompleteUI = /** @class */ (function () {
|
|
|
1743
1759
|
this.debouncedFetchResults = this.debounce(this.fetchResults, this.config.debounceMS);
|
|
1744
1760
|
this.results = [];
|
|
1745
1761
|
this.highlightedIndex = -1;
|
|
1762
|
+
if (options.near) {
|
|
1763
|
+
if (typeof options.near === 'string') {
|
|
1764
|
+
this.near = options.near;
|
|
1765
|
+
}
|
|
1766
|
+
else {
|
|
1767
|
+
this.near = "".concat(options.near.latitude, ",").concat(options.near.longitude);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1746
1770
|
// get container element
|
|
1747
1771
|
var containerEL;
|
|
1748
1772
|
if (typeof this.config.container === 'string') { // lookup container element by ID
|
|
@@ -1856,17 +1880,23 @@ var AutocompleteUI = /** @class */ (function () {
|
|
|
1856
1880
|
};
|
|
1857
1881
|
AutocompleteUI.prototype.fetchResults = function (query) {
|
|
1858
1882
|
return __awaiter(this, void 0, void 0, function () {
|
|
1859
|
-
var _a, limit, layers, countryCode, params, addresses;
|
|
1883
|
+
var _a, limit, layers, countryCode, onRequest, params, addresses;
|
|
1860
1884
|
return __generator(this, function (_b) {
|
|
1861
1885
|
switch (_b.label) {
|
|
1862
1886
|
case 0:
|
|
1863
|
-
_a = this.config, limit = _a.limit, layers = _a.layers, countryCode = _a.countryCode;
|
|
1887
|
+
_a = this.config, limit = _a.limit, layers = _a.layers, countryCode = _a.countryCode, onRequest = _a.onRequest;
|
|
1864
1888
|
params = {
|
|
1865
1889
|
query: query,
|
|
1866
1890
|
limit: limit,
|
|
1867
1891
|
layers: layers,
|
|
1868
1892
|
countryCode: countryCode,
|
|
1869
1893
|
};
|
|
1894
|
+
if (this.near) {
|
|
1895
|
+
params.near = this.near;
|
|
1896
|
+
}
|
|
1897
|
+
if (onRequest) {
|
|
1898
|
+
onRequest(params);
|
|
1899
|
+
}
|
|
1870
1900
|
return [4 /*yield*/, SearchAPI.autocomplete(params)];
|
|
1871
1901
|
case 1:
|
|
1872
1902
|
addresses = (_b.sent()).addresses;
|
|
@@ -2042,10 +2072,21 @@ var AutocompleteUI = /** @class */ (function () {
|
|
|
2042
2072
|
};
|
|
2043
2073
|
// remove elements from DOM
|
|
2044
2074
|
AutocompleteUI.prototype.remove = function () {
|
|
2075
|
+
Logger.debug('AutocompleteUI removed.');
|
|
2045
2076
|
this.inputField.remove();
|
|
2046
2077
|
this.resultsList.remove();
|
|
2047
2078
|
this.wrapper.remove();
|
|
2048
2079
|
};
|
|
2080
|
+
AutocompleteUI.prototype.setNear = function (near) {
|
|
2081
|
+
if (near) {
|
|
2082
|
+
if (typeof near === 'string') {
|
|
2083
|
+
this.near = near;
|
|
2084
|
+
}
|
|
2085
|
+
else {
|
|
2086
|
+
this.near = "".concat(near.latitude, ",").concat(near.longitude);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2049
2090
|
return AutocompleteUI;
|
|
2050
2091
|
}());
|
|
2051
2092
|
|
package/dist/radar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -341,6 +341,7 @@ export interface RadarMarkerOptions {
|
|
|
341
341
|
}
|
|
342
342
|
export interface RadarAutocompleteUIOptions {
|
|
343
343
|
container: string | HTMLElement;
|
|
344
|
+
near?: string | Location;
|
|
344
345
|
debounceMS?: number;
|
|
345
346
|
threshold?: number;
|
|
346
347
|
limit?: number;
|
|
@@ -348,6 +349,7 @@ export interface RadarAutocompleteUIOptions {
|
|
|
348
349
|
countryCode?: string;
|
|
349
350
|
placeholder?: string;
|
|
350
351
|
onSelection?: (selection: any) => void;
|
|
352
|
+
onRequest?: (params: RadarAutocompleteParams) => void;
|
|
351
353
|
onResults?: (results: any[]) => void;
|
|
352
354
|
onError?: (error: any) => void;
|
|
353
355
|
disabled?: boolean;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig } from '../types';
|
|
1
|
+
import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, Location } from '../types';
|
|
2
2
|
declare class AutocompleteUI {
|
|
3
3
|
config: RadarAutocompleteConfig;
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
results: any[];
|
|
6
6
|
highlightedIndex: number;
|
|
7
7
|
debouncedFetchResults: (...args: any[]) => Promise<any>;
|
|
8
|
+
near?: string;
|
|
8
9
|
container: HTMLElement;
|
|
9
10
|
inputField: HTMLInputElement;
|
|
10
11
|
resultsList: HTMLElement;
|
|
@@ -23,5 +24,6 @@ declare class AutocompleteUI {
|
|
|
23
24
|
select(index: number): void;
|
|
24
25
|
clearResultsList(): void;
|
|
25
26
|
remove(): void;
|
|
27
|
+
setNear(near: string | Location): void;
|
|
26
28
|
}
|
|
27
29
|
export default AutocompleteUI;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.1.
|
|
1
|
+
declare const _default: "4.1.2-beta.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -456,6 +456,7 @@ export interface RadarMarkerOptions {
|
|
|
456
456
|
|
|
457
457
|
export interface RadarAutocompleteUIOptions {
|
|
458
458
|
container: string | HTMLElement;
|
|
459
|
+
near?: string | Location; // bias for location results
|
|
459
460
|
debounceMS?: number, // Debounce time in milliseconds
|
|
460
461
|
threshold?: number, // Minimum number of characters to trigger autocomplete
|
|
461
462
|
limit?: number, // Maximum number of autocomplete results
|
|
@@ -463,6 +464,7 @@ export interface RadarAutocompleteUIOptions {
|
|
|
463
464
|
countryCode?: string;
|
|
464
465
|
placeholder?: string, // Placeholder text for the input field
|
|
465
466
|
onSelection?: (selection: any) => void,
|
|
467
|
+
onRequest?: (params: RadarAutocompleteParams) => void,
|
|
466
468
|
onResults?: (results: any[]) => void,
|
|
467
469
|
onError?: (error: any) => void,
|
|
468
470
|
disabled?: boolean,
|
package/src/ui/autocomplete.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Logger from '../logger';
|
|
|
2
2
|
import SearchAPI from '../api/search';
|
|
3
3
|
|
|
4
4
|
import { RadarAutocompleteContainerNotFound } from '../errors';
|
|
5
|
-
import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams } from '../types';
|
|
5
|
+
import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location } from '../types';
|
|
6
6
|
|
|
7
7
|
const CLASSNAMES = {
|
|
8
8
|
WRAPPER: 'radar-autocomplete-wrapper',
|
|
@@ -68,6 +68,7 @@ class AutocompleteUI {
|
|
|
68
68
|
results: any[];
|
|
69
69
|
highlightedIndex: number;
|
|
70
70
|
debouncedFetchResults: (...args: any[]) => Promise<any>;
|
|
71
|
+
near?: string;
|
|
71
72
|
|
|
72
73
|
// DOM elements
|
|
73
74
|
container: HTMLElement;
|
|
@@ -90,6 +91,14 @@ class AutocompleteUI {
|
|
|
90
91
|
this.results = [];
|
|
91
92
|
this.highlightedIndex = -1;
|
|
92
93
|
|
|
94
|
+
if (options.near) {
|
|
95
|
+
if (typeof options.near === 'string') {
|
|
96
|
+
this.near = options.near;
|
|
97
|
+
} else {
|
|
98
|
+
this.near = `${options.near.latitude},${options.near.longitude}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
// get container element
|
|
94
103
|
let containerEL;
|
|
95
104
|
if (typeof this.config.container === 'string') { // lookup container element by ID
|
|
@@ -208,7 +217,7 @@ class AutocompleteUI {
|
|
|
208
217
|
}
|
|
209
218
|
|
|
210
219
|
public async fetchResults(query: string) {
|
|
211
|
-
const { limit, layers, countryCode } = this.config;
|
|
220
|
+
const { limit, layers, countryCode, onRequest } = this.config;
|
|
212
221
|
|
|
213
222
|
const params: RadarAutocompleteParams = {
|
|
214
223
|
query,
|
|
@@ -217,6 +226,14 @@ class AutocompleteUI {
|
|
|
217
226
|
countryCode,
|
|
218
227
|
}
|
|
219
228
|
|
|
229
|
+
if (this.near) {
|
|
230
|
+
params.near = this.near;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (onRequest) {
|
|
234
|
+
onRequest(params);
|
|
235
|
+
}
|
|
236
|
+
|
|
220
237
|
const { addresses } = await SearchAPI.autocomplete(params);
|
|
221
238
|
return addresses;
|
|
222
239
|
}
|
|
@@ -416,10 +433,21 @@ class AutocompleteUI {
|
|
|
416
433
|
|
|
417
434
|
// remove elements from DOM
|
|
418
435
|
public remove() {
|
|
436
|
+
Logger.debug('AutocompleteUI removed.');
|
|
419
437
|
this.inputField.remove();
|
|
420
438
|
this.resultsList.remove();
|
|
421
439
|
this.wrapper.remove();
|
|
422
440
|
}
|
|
441
|
+
|
|
442
|
+
public setNear(near: string | Location) {
|
|
443
|
+
if (near) {
|
|
444
|
+
if (typeof near === 'string') {
|
|
445
|
+
this.near = near;
|
|
446
|
+
} else {
|
|
447
|
+
this.near = `${near.latitude},${near.longitude}`;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
423
451
|
}
|
|
424
452
|
|
|
425
453
|
export default AutocompleteUI;
|
package/src/ui/map.ts
CHANGED
|
@@ -7,6 +7,12 @@ import type { RadarOptions, RadarMapOptions, RadarMarkerOptions } from '../types
|
|
|
7
7
|
|
|
8
8
|
const DEFAULT_STYLE = 'radar-default-v1';
|
|
9
9
|
|
|
10
|
+
const RADAR_STYLES = [
|
|
11
|
+
'radar-default-v1',
|
|
12
|
+
'radar-light-v1',
|
|
13
|
+
'radar-dark-v1',
|
|
14
|
+
];
|
|
15
|
+
|
|
10
16
|
const RADAR_LOGO_URL = 'https://api.radar.io/maps/static/images/logo.svg';
|
|
11
17
|
|
|
12
18
|
const defaultMaplibreOptions: Partial<maplibregl.MapOptions> = {
|
|
@@ -28,9 +34,12 @@ const createStyleURL = (options: RadarOptions, style: string = DEFAULT_STYLE) =>
|
|
|
28
34
|
|
|
29
35
|
// use formatted style URL if using one of Radar's out-of-the-box styles
|
|
30
36
|
const getStyle = (options: RadarOptions, mapOptions: RadarMapOptions) => {
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
const style = mapOptions.style;
|
|
38
|
+
|
|
39
|
+
if (!style || (typeof style === 'string' && RADAR_STYLES.includes(style))) {
|
|
40
|
+
return createStyleURL(options, mapOptions.style as string);
|
|
33
41
|
}
|
|
42
|
+
|
|
34
43
|
return mapOptions.style;
|
|
35
44
|
};
|
|
36
45
|
|
|
@@ -50,14 +59,24 @@ class MapUI {
|
|
|
50
59
|
const style = getStyle(options, mapOptions);
|
|
51
60
|
const maplibreOptions: maplibregl.MapOptions = Object.assign({},
|
|
52
61
|
defaultMaplibreOptions,
|
|
53
|
-
{ style },
|
|
54
62
|
mapOptions,
|
|
63
|
+
{ style },
|
|
55
64
|
);
|
|
56
65
|
Logger.debug(`initialize map with options: ${JSON.stringify(maplibreOptions)}`);
|
|
57
66
|
|
|
58
67
|
// set container
|
|
59
68
|
maplibreOptions.container = mapOptions.container;
|
|
60
69
|
|
|
70
|
+
// custom request handler for Radar styles
|
|
71
|
+
maplibreOptions.transformRequest = (url, resourceType) => {
|
|
72
|
+
if (resourceType === 'Style' && RADAR_STYLES.includes(url)) {
|
|
73
|
+
const radarStyleURL = createStyleURL(options, url);
|
|
74
|
+
return { url: radarStyleURL };
|
|
75
|
+
} else {
|
|
76
|
+
return { url };
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
61
80
|
// create map
|
|
62
81
|
const map = new maplibregl.Map(maplibreOptions);
|
|
63
82
|
const container = map.getContainer();
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.1.
|
|
1
|
+
export default '4.1.2-beta.0';
|