@deck.gl/widgets 9.1.11 → 9.2.0-alpha.1
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/dist/compass-widget.d.ts +11 -34
- package/dist/compass-widget.d.ts.map +1 -1
- package/dist/compass-widget.js +27 -62
- package/dist/compass-widget.js.map +1 -1
- package/dist/context-menu-widget.d.ts +37 -0
- package/dist/context-menu-widget.d.ts.map +1 -0
- package/dist/context-menu-widget.js +74 -0
- package/dist/context-menu-widget.js.map +1 -0
- package/dist/dist.dev.js +2271 -581
- package/dist/fps-widget.d.ts +29 -0
- package/dist/fps-widget.d.ts.map +1 -0
- package/dist/fps-widget.js +51 -0
- package/dist/fps-widget.js.map +1 -0
- package/dist/fullscreen-widget.d.ts +15 -33
- package/dist/fullscreen-widget.d.ts.map +1 -1
- package/dist/fullscreen-widget.js +20 -51
- package/dist/fullscreen-widget.js.map +1 -1
- package/dist/geocoder-widget.d.ts +51 -0
- package/dist/geocoder-widget.d.ts.map +1 -0
- package/dist/geocoder-widget.js +138 -0
- package/dist/geocoder-widget.js.map +1 -0
- package/dist/gimbal-widget.d.ts +33 -0
- package/dist/gimbal-widget.d.ts.map +1 -0
- package/dist/gimbal-widget.js +116 -0
- package/dist/gimbal-widget.js.map +1 -0
- package/dist/index.cjs +1587 -341
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +37 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/info-widget.d.ts +37 -0
- package/dist/info-widget.d.ts.map +1 -0
- package/dist/info-widget.js +183 -0
- package/dist/info-widget.js.map +1 -0
- package/dist/lib/components/button-group.d.ts +8 -0
- package/dist/lib/components/button-group.d.ts.map +1 -0
- package/dist/lib/components/button-group.js +7 -0
- package/dist/lib/components/button-group.js.map +1 -0
- package/dist/lib/components/dropdown-menu.d.ts +8 -0
- package/dist/lib/components/dropdown-menu.d.ts.map +1 -0
- package/dist/lib/components/dropdown-menu.js +55 -0
- package/dist/lib/components/dropdown-menu.js.map +1 -0
- package/dist/lib/components/grouped-icon-button.d.ts +8 -0
- package/dist/lib/components/grouped-icon-button.d.ts.map +1 -0
- package/dist/lib/components/grouped-icon-button.js +7 -0
- package/dist/lib/components/grouped-icon-button.js.map +1 -0
- package/dist/lib/components/icon-button.d.ts +11 -0
- package/dist/lib/components/icon-button.d.ts.map +1 -0
- package/dist/lib/components/icon-button.js +7 -0
- package/dist/lib/components/icon-button.js.map +1 -0
- package/dist/lib/components/icon-menu.d.ts +16 -0
- package/dist/lib/components/icon-menu.d.ts.map +1 -0
- package/dist/lib/components/icon-menu.js +49 -0
- package/dist/lib/components/icon-menu.js.map +1 -0
- package/dist/lib/components/simple-menu.d.ts +16 -0
- package/dist/lib/components/simple-menu.d.ts.map +1 -0
- package/dist/lib/components/simple-menu.js +30 -0
- package/dist/lib/components/simple-menu.js.map +1 -0
- package/dist/lib/geocode/geocoder-history.d.ts +23 -0
- package/dist/lib/geocode/geocoder-history.d.ts.map +1 -0
- package/dist/lib/geocode/geocoder-history.js +64 -0
- package/dist/lib/geocode/geocoder-history.js.map +1 -0
- package/dist/lib/geocode/geocoder.d.ts +15 -0
- package/dist/lib/geocode/geocoder.d.ts.map +1 -0
- package/dist/lib/geocode/geocoder.js +5 -0
- package/dist/lib/geocode/geocoder.js.map +1 -0
- package/dist/lib/geocode/geocoders.d.ts +68 -0
- package/dist/lib/geocode/geocoders.d.ts.map +1 -0
- package/dist/lib/geocode/geocoders.js +182 -0
- package/dist/lib/geocode/geocoders.js.map +1 -0
- package/dist/loading-widget.d.ts +26 -0
- package/dist/loading-widget.d.ts.map +1 -0
- package/dist/loading-widget.js +41 -0
- package/dist/loading-widget.js.map +1 -0
- package/dist/reset-view-widget.d.ts +4 -4
- package/dist/reset-view-widget.d.ts.map +1 -1
- package/dist/reset-view-widget.js +7 -10
- package/dist/reset-view-widget.js.map +1 -1
- package/dist/scale-widget.d.ts +28 -0
- package/dist/scale-widget.d.ts.map +1 -0
- package/dist/scale-widget.js +111 -0
- package/dist/scale-widget.js.map +1 -0
- package/dist/screenshot-widget.d.ts +4 -4
- package/dist/screenshot-widget.d.ts.map +1 -1
- package/dist/screenshot-widget.js +7 -14
- package/dist/screenshot-widget.js.map +1 -1
- package/dist/splitter-widget.d.ts +32 -0
- package/dist/splitter-widget.d.ts.map +1 -0
- package/dist/splitter-widget.js +123 -0
- package/dist/splitter-widget.js.map +1 -0
- package/dist/stats-widget.d.ts +36 -0
- package/dist/stats-widget.d.ts.map +1 -0
- package/dist/stats-widget.js +115 -0
- package/dist/stats-widget.js.map +1 -0
- package/dist/stylesheet.css +121 -4
- package/dist/theme-widget.d.ts +31 -0
- package/dist/theme-widget.d.ts.map +1 -0
- package/dist/theme-widget.js +83 -0
- package/dist/theme-widget.js.map +1 -0
- package/dist/themes.d.ts +65 -36
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +20 -8
- package/dist/themes.js.map +1 -1
- package/dist/timeline-widget.d.ts +59 -0
- package/dist/timeline-widget.d.ts.map +1 -0
- package/dist/timeline-widget.js +83 -0
- package/dist/timeline-widget.js.map +1 -0
- package/dist/view-selector-widget.d.ts +33 -0
- package/dist/view-selector-widget.d.ts.map +1 -0
- package/dist/view-selector-widget.js +62 -0
- package/dist/view-selector-widget.js.map +1 -0
- package/dist/zoom-widget.d.ts +14 -43
- package/dist/zoom-widget.d.ts.map +1 -1
- package/dist/zoom-widget.js +14 -56
- package/dist/zoom-widget.js.map +1 -1
- package/dist.min.js +3 -1
- package/package.json +4 -3
- package/src/compass-widget.tsx +44 -106
- package/src/context-menu-widget.tsx +115 -0
- package/src/fps-widget.tsx +67 -0
- package/src/fullscreen-widget.tsx +33 -86
- package/src/geocoder-widget.tsx +209 -0
- package/src/gimbal-widget.tsx +188 -0
- package/src/index.ts +58 -8
- package/src/info-widget.tsx +225 -0
- package/src/lib/components/button-group.tsx +16 -0
- package/src/lib/components/dropdown-menu.tsx +98 -0
- package/src/lib/components/grouped-icon-button.tsx +24 -0
- package/src/lib/components/icon-button.tsx +30 -0
- package/src/lib/components/icon-menu.tsx +89 -0
- package/src/lib/components/simple-menu.tsx +52 -0
- package/src/lib/geocode/geocoder-history.ts +73 -0
- package/src/lib/geocode/geocoder.ts +15 -0
- package/src/lib/geocode/geocoders.ts +199 -0
- package/src/loading-widget.tsx +67 -0
- package/src/reset-view-widget.tsx +8 -11
- package/src/scale-widget.tsx +183 -0
- package/src/screenshot-widget.tsx +9 -11
- package/src/splitter-widget.tsx +179 -0
- package/src/stats-widget.tsx +166 -0
- package/src/stylesheet.css +121 -4
- package/src/theme-widget.tsx +120 -0
- package/src/themes.ts +45 -12
- package/src/timeline-widget.tsx +155 -0
- package/src/view-selector-widget.tsx +108 -0
- package/src/zoom-widget.tsx +39 -113
- package/dist/components.d.ts +0 -4
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -17
- package/dist/components.js.map +0 -1
- package/dist/widget-impl.d.ts +0 -29
- package/dist/widget-impl.d.ts.map +0 -1
- package/dist/widget-impl.js +0 -60
- package/dist/widget-impl.js.map +0 -1
- package/src/components.tsx +0 -38
- package/src/widget-impl.ts +0 -88
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A geocoder that translates an address string into a location */
|
|
2
|
+
export type Geocoder = {
|
|
3
|
+
/** The name of the geocoder, e.g. google, mapbox, ... */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Does the geocoder require an api key? */
|
|
6
|
+
requiresApiKey?: boolean;
|
|
7
|
+
/** A string that can be used to indicate the accepted format */
|
|
8
|
+
placeholderLocation?: string;
|
|
9
|
+
/** Calls the geocoder service, translating an address string into a location */
|
|
10
|
+
geocode(address: string, apiKey: string): Promise<{
|
|
11
|
+
longitude: number;
|
|
12
|
+
latitude: number;
|
|
13
|
+
} | null>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=geocoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../src/lib/geocode/geocoder.ts"],"names":[],"mappings":"AAIA,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG;IACrB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gEAAgE;IAChE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gFAAgF;IAChF,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC,CAAC;CACjG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoder.js","sourceRoot":"","sources":["../../../src/lib/geocode/geocoder.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A geocoder that uses the google geocoding service
|
|
3
|
+
* @note Requires an API key from Google
|
|
4
|
+
* @see https://developers.google.com/maps/documentation/geocoding/get-api-key
|
|
5
|
+
*/
|
|
6
|
+
export declare const GoogleGeocoder: {
|
|
7
|
+
readonly name: "google";
|
|
8
|
+
readonly requiresApiKey: true;
|
|
9
|
+
readonly geocode: (address: string, apiKey: string) => Promise<{
|
|
10
|
+
longitude: number;
|
|
11
|
+
latitude: number;
|
|
12
|
+
} | null>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A geocoder that uses the google geocoding service
|
|
16
|
+
* @note Requires an API key from Mapbox
|
|
17
|
+
* @see https://docs.mapbox.com/api/search/geocoding/
|
|
18
|
+
*/
|
|
19
|
+
export declare const MapboxGeocoder: {
|
|
20
|
+
readonly name: "google";
|
|
21
|
+
readonly requiresApiKey: true;
|
|
22
|
+
readonly geocode: (address: string, apiKey: string) => Promise<{
|
|
23
|
+
longitude: number;
|
|
24
|
+
latitude: number;
|
|
25
|
+
} | null>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A geocoder that uses the google geocoding service
|
|
29
|
+
* @note Requires an API key from OpenCageData
|
|
30
|
+
* @see https://opencagedata.com/api
|
|
31
|
+
*/
|
|
32
|
+
export declare const OpenCageGeocoder: {
|
|
33
|
+
readonly name: "opencage";
|
|
34
|
+
readonly requiresApiKey: true;
|
|
35
|
+
readonly geocode: (address: string, key: string) => Promise<{
|
|
36
|
+
longitude: number;
|
|
37
|
+
latitude: number;
|
|
38
|
+
} | null>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* A geocoder adapter that wraps the browser's geolocation API. Always returns the user's current location.
|
|
42
|
+
* @note Not technically a geocoder, but a geolocation service that provides a source of locations.
|
|
43
|
+
* @note The user must allow location access for this to work.
|
|
44
|
+
*/
|
|
45
|
+
export declare const CurrentLocationGeocoder: {
|
|
46
|
+
readonly name: "current";
|
|
47
|
+
readonly requiresApiKey: false;
|
|
48
|
+
/** Attempt to call browsers geolocation API */
|
|
49
|
+
readonly geocode: () => Promise<{
|
|
50
|
+
longitude: number;
|
|
51
|
+
latitude: number;
|
|
52
|
+
} | null>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Parse a coordinate string.
|
|
56
|
+
* Supports comma- or semicolon-separated values.
|
|
57
|
+
* Heuristically determines which value is longitude and which is latitude.
|
|
58
|
+
*/
|
|
59
|
+
export declare const CoordinatesGeocoder: {
|
|
60
|
+
readonly name: "coordinates";
|
|
61
|
+
readonly requiresApiKey: false;
|
|
62
|
+
readonly placeholderLocation: "-122.45, 37.8 or 37°48'N, 122°27'W";
|
|
63
|
+
readonly geocode: (address: string) => Promise<{
|
|
64
|
+
longitude: number;
|
|
65
|
+
latitude: number;
|
|
66
|
+
} | null>;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=geocoders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoders.d.ts","sourceRoot":"","sources":["../../../src/lib/geocode/geocoders.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;gCAId,MAAM,UACP,MAAM,KACb,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;CAY7B,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;gCAId,MAAM,UACP,MAAM,KACb,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;CAY7B,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;gCAIhB,MAAM,OACV,MAAM,KACV,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;CAS7B,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;IAGlC,+CAA+C;4BAC9B,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;CAgB3C,CAAC;AAqB9B;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;gCAIP,MAAM,KAAG,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI,CAAC;CAG1D,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
const GOOGLE_URL = 'https://maps.googleapis.com/maps/api/geocode/json';
|
|
5
|
+
const MAPBOX_URL = 'https://api.mapbox.com/geocoding/v5/mapbox.places';
|
|
6
|
+
const OPENCAGE_API_URL = 'https://api.opencagedata.com/geocode/v1/json';
|
|
7
|
+
/**
|
|
8
|
+
* A geocoder that uses the google geocoding service
|
|
9
|
+
* @note Requires an API key from Google
|
|
10
|
+
* @see https://developers.google.com/maps/documentation/geocoding/get-api-key
|
|
11
|
+
*/
|
|
12
|
+
export const GoogleGeocoder = {
|
|
13
|
+
name: 'google',
|
|
14
|
+
requiresApiKey: true,
|
|
15
|
+
async geocode(address, apiKey) {
|
|
16
|
+
const encodedAddress = encodeURIComponent(address);
|
|
17
|
+
const json = await fetchJson(`${GOOGLE_URL}?address=${encodedAddress}&key=${apiKey}`);
|
|
18
|
+
switch (json.status) {
|
|
19
|
+
case 'OK':
|
|
20
|
+
const loc = json.results.length > 0 && json.results[0].geometry.location;
|
|
21
|
+
return loc ? { longitude: loc.lng, latitude: loc.lat } : null;
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`Google Geocoder failed: ${json.status}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A geocoder that uses the google geocoding service
|
|
29
|
+
* @note Requires an API key from Mapbox
|
|
30
|
+
* @see https://docs.mapbox.com/api/search/geocoding/
|
|
31
|
+
*/
|
|
32
|
+
export const MapboxGeocoder = {
|
|
33
|
+
name: 'google',
|
|
34
|
+
requiresApiKey: true,
|
|
35
|
+
async geocode(address, apiKey) {
|
|
36
|
+
const encodedAddress = encodeURIComponent(address);
|
|
37
|
+
const json = await fetchJson(`${MAPBOX_URL}/${encodedAddress}.json?access_token=${apiKey}`);
|
|
38
|
+
if (Array.isArray(json.features) && json.features.length > 0) {
|
|
39
|
+
const center = json.features[0].center;
|
|
40
|
+
if (Array.isArray(center) && center.length >= 2) {
|
|
41
|
+
return { longitude: center[0], latitude: center[1] };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A geocoder that uses the google geocoding service
|
|
49
|
+
* @note Requires an API key from OpenCageData
|
|
50
|
+
* @see https://opencagedata.com/api
|
|
51
|
+
*/
|
|
52
|
+
export const OpenCageGeocoder = {
|
|
53
|
+
name: 'opencage',
|
|
54
|
+
requiresApiKey: true,
|
|
55
|
+
async geocode(address, key) {
|
|
56
|
+
const encodedAddress = encodeURIComponent(address);
|
|
57
|
+
const data = await fetchJson(`${OPENCAGE_API_URL}?q=${encodedAddress}&key=${key}`);
|
|
58
|
+
if (Array.isArray(data.results) && data.results.length > 0) {
|
|
59
|
+
const geometry = data.results[0].geometry;
|
|
60
|
+
return { longitude: geometry.lng, latitude: geometry.lat };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A geocoder adapter that wraps the browser's geolocation API. Always returns the user's current location.
|
|
67
|
+
* @note Not technically a geocoder, but a geolocation service that provides a source of locations.
|
|
68
|
+
* @note The user must allow location access for this to work.
|
|
69
|
+
*/
|
|
70
|
+
export const CurrentLocationGeocoder = {
|
|
71
|
+
name: 'current',
|
|
72
|
+
requiresApiKey: false,
|
|
73
|
+
/** Attempt to call browsers geolocation API */
|
|
74
|
+
async geocode() {
|
|
75
|
+
if (!navigator.geolocation) {
|
|
76
|
+
throw new Error('Geolocation not supported');
|
|
77
|
+
}
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
navigator.geolocation.getCurrentPosition(
|
|
80
|
+
/** @see https://developer.mozilla.org/docs/Web/API/GeolocationPosition */
|
|
81
|
+
(position) => {
|
|
82
|
+
const { longitude, latitude } = position.coords;
|
|
83
|
+
resolve({ longitude, latitude });
|
|
84
|
+
},
|
|
85
|
+
/** @see https://developer.mozilla.org/docs/Web/API/GeolocationPositionError */
|
|
86
|
+
(error) => reject(new Error(error.message)));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
/** Fetch JSON, catching HTTP errors */
|
|
91
|
+
async function fetchJson(url) {
|
|
92
|
+
let response;
|
|
93
|
+
try {
|
|
94
|
+
response = await fetch(url);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// Annoyingly, fetch reports some errors (e.g. CORS) using excpetions, not response.ok
|
|
98
|
+
throw new Error(`CORS error? ${error}. ${url}: `);
|
|
99
|
+
}
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
throw new Error(`${response.statusText}. ${url}: `);
|
|
102
|
+
}
|
|
103
|
+
const data = await response.json();
|
|
104
|
+
if (!data) {
|
|
105
|
+
throw new Error(`No data returned. ${url}`);
|
|
106
|
+
}
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parse a coordinate string.
|
|
111
|
+
* Supports comma- or semicolon-separated values.
|
|
112
|
+
* Heuristically determines which value is longitude and which is latitude.
|
|
113
|
+
*/
|
|
114
|
+
export const CoordinatesGeocoder = {
|
|
115
|
+
name: 'coordinates',
|
|
116
|
+
requiresApiKey: false,
|
|
117
|
+
placeholderLocation: `-122.45, 37.8 or 37°48'N, 122°27'W`,
|
|
118
|
+
async geocode(address) {
|
|
119
|
+
return parseCoordinates(address) || null;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Parse an input string for coordinates.
|
|
124
|
+
* Supports comma- or semicolon-separated values.
|
|
125
|
+
* Heuristically determines which value is longitude and which is latitude.
|
|
126
|
+
*/
|
|
127
|
+
function parseCoordinates(input) {
|
|
128
|
+
input = input.trim();
|
|
129
|
+
const parts = input.split(/[,;]/).map(p => p.trim());
|
|
130
|
+
if (parts.length < 2)
|
|
131
|
+
return null;
|
|
132
|
+
const first = parseCoordinatePart(parts[0]);
|
|
133
|
+
const second = parseCoordinatePart(parts[1]);
|
|
134
|
+
if (first === null || second === null)
|
|
135
|
+
return null;
|
|
136
|
+
// Use a heuristic:
|
|
137
|
+
// If one number exceeds 90 in absolute value, it's likely a longitude.
|
|
138
|
+
if (Math.abs(first) > 90 && Math.abs(second) <= 90) {
|
|
139
|
+
return { longitude: first, latitude: second };
|
|
140
|
+
}
|
|
141
|
+
else if (Math.abs(second) > 90 && Math.abs(first) <= 90) {
|
|
142
|
+
return { longitude: second, latitude: first };
|
|
143
|
+
}
|
|
144
|
+
// If both are <= 90, assume order: latitude, longitude.
|
|
145
|
+
return { latitude: first, longitude: second };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Parse a single coordinate part (which may be in decimal or DMS format).
|
|
149
|
+
*/
|
|
150
|
+
function parseCoordinatePart(s) {
|
|
151
|
+
s = s.trim();
|
|
152
|
+
// If the string contains a degree symbol or similar markers, use DMS parsing.
|
|
153
|
+
if (s.includes('°') || s.includes("'") || s.includes('"')) {
|
|
154
|
+
const value = dmsToDecimal(s);
|
|
155
|
+
return isNaN(value) ? null : value;
|
|
156
|
+
}
|
|
157
|
+
// Otherwise, check for a cardinal letter and remove it.
|
|
158
|
+
let sign = 1;
|
|
159
|
+
if (/[SW]/i.test(s))
|
|
160
|
+
sign = -1;
|
|
161
|
+
s = s.replace(/[NSEW]/gi, '');
|
|
162
|
+
const value = parseFloat(s);
|
|
163
|
+
return isNaN(value) ? null : sign * value;
|
|
164
|
+
}
|
|
165
|
+
/** Convert a DMS string (e.g. "37°48'00\"N") to decimal degrees. */
|
|
166
|
+
function dmsToDecimal(s) {
|
|
167
|
+
// A simple regex to extract degrees, minutes, seconds and direction.
|
|
168
|
+
const regex = /(\d+)[°d]\s*(\d+)?['′m]?\s*(\d+(?:\.\d+)?)?[\"″s]?\s*([NSEW])?/i;
|
|
169
|
+
const match = s.match(regex);
|
|
170
|
+
if (!match)
|
|
171
|
+
return NaN;
|
|
172
|
+
const degrees = parseFloat(match[1]) || 0;
|
|
173
|
+
const minutes = parseFloat(match[2]) || 0;
|
|
174
|
+
const seconds = parseFloat(match[3]) || 0;
|
|
175
|
+
const direction = match[4] || '';
|
|
176
|
+
let dec = degrees + minutes / 60 + seconds / 3600;
|
|
177
|
+
if (/[SW]/i.test(direction)) {
|
|
178
|
+
dec = -dec;
|
|
179
|
+
}
|
|
180
|
+
return dec;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=geocoders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoders.js","sourceRoot":"","sources":["../../../src/lib/geocode/geocoders.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,UAAU,GAAG,mDAAmD,CAAC;AACvE,MAAM,UAAU,GAAG,mDAAmD,CAAC;AACvE,MAAM,gBAAgB,GAAG,8CAA8C,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,cAAc,EAAE,IAAI;IACpB,KAAK,CAAC,OAAO,CACX,OAAe,EACf,MAAc;QAEd,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,UAAU,YAAY,cAAc,QAAQ,MAAM,EAAE,CAAC,CAAC;QAEtF,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YACpB,KAAK,IAAI;gBACP,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACzE,OAAO,GAAG,CAAC,CAAC,CAAC,EAAC,SAAS,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC9D;gBACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CAC0B,CAAC;AAE9B;;;;GAIG;AACH,M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oEAAoE;AACpE,SAAS,YAAY,CAAC,CAAS;IAC7B,qEAAqE;IACrE,MAAM,KAAK,GAAG,iEAAiE,CAAC;IAChF,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,KAAK;QAAE,OAAO,GAAG,CAAC;IACvB,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,IAAI,GAAG,GAAG,OAAO,GAAG,OAAO,GAAG,EAAE,GAAG,OAAO,GAAG,IAAI,CAAC;IAClD,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,GAAG,GAAG,CAAC,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WidgetPlacement, Layer } from '@deck.gl/core';
|
|
2
|
+
import { Widget, WidgetProps } from '@deck.gl/core';
|
|
3
|
+
/** Properties for the LoadingWidget */
|
|
4
|
+
export type LoadingWidgetProps = WidgetProps & {
|
|
5
|
+
/** Widget positioning within the view. Default 'top-left'. */
|
|
6
|
+
placement?: WidgetPlacement;
|
|
7
|
+
/** Tooltip message when loading */
|
|
8
|
+
label?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A non-interactive widget that shows a loading spinner if any layers are loading data
|
|
12
|
+
*/
|
|
13
|
+
export declare class LoadingWidget extends Widget<LoadingWidgetProps> {
|
|
14
|
+
static defaultProps: Required<LoadingWidgetProps>;
|
|
15
|
+
className: string;
|
|
16
|
+
placement: WidgetPlacement;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
constructor(props?: LoadingWidgetProps);
|
|
19
|
+
setProps(props: Partial<LoadingWidgetProps>): void;
|
|
20
|
+
onRenderHTML(rootElement: HTMLElement): void;
|
|
21
|
+
onRedraw({ layers }: {
|
|
22
|
+
layers: Layer[];
|
|
23
|
+
}): void;
|
|
24
|
+
handleClick(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=loading-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-widget.d.ts","sourceRoot":"","sources":["../src/loading-widget.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAGlD,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,8DAA8D;IAC9D,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,kBAAkB,CAAC;IAC3D,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAK/C;IAEF,SAAS,SAAyB;IAClC,SAAS,EAAE,eAAe,CAAc;IACxC,OAAO,UAAQ;gBAEH,KAAK,GAAE,kBAAuB;IAK1C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAK3C,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAc5C,QAAQ,CAAC,EAAC,MAAM,EAAC,EAAE;QAAC,MAAM,EAAE,KAAK,EAAE,CAAA;KAAC,GAAG,IAAI;IAS3C,WAAW;CACZ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { render } from 'preact';
|
|
3
|
+
import { Widget } from '@deck.gl/core';
|
|
4
|
+
import { IconButton } from "./lib/components/icon-button.js";
|
|
5
|
+
/**
|
|
6
|
+
* A non-interactive widget that shows a loading spinner if any layers are loading data
|
|
7
|
+
*/
|
|
8
|
+
export class LoadingWidget extends Widget {
|
|
9
|
+
constructor(props = {}) {
|
|
10
|
+
super(props, LoadingWidget.defaultProps);
|
|
11
|
+
this.className = 'deck-widget-loading';
|
|
12
|
+
this.placement = 'top-left';
|
|
13
|
+
this.loading = true;
|
|
14
|
+
this.placement = props.placement ?? this.placement;
|
|
15
|
+
}
|
|
16
|
+
setProps(props) {
|
|
17
|
+
this.placement = props.placement ?? this.placement;
|
|
18
|
+
super.setProps(props);
|
|
19
|
+
}
|
|
20
|
+
onRenderHTML(rootElement) {
|
|
21
|
+
render(
|
|
22
|
+
// TODO(ibgreen) - this should not be a button, but styling is so nested that it is easier to reuse this component.
|
|
23
|
+
this.loading && (_jsx(IconButton, { className: "deck-widget-spinner-icon", label: this.props.label, onClick: this.handleClick.bind(this) })), rootElement);
|
|
24
|
+
}
|
|
25
|
+
onRedraw({ layers }) {
|
|
26
|
+
const loading = !layers.some(layer => !layer.isLoaded);
|
|
27
|
+
if (loading !== this.loading) {
|
|
28
|
+
this.loading = loading;
|
|
29
|
+
this.updateHTML();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// TODO(ibgreen) - this should not be a button, see above.
|
|
33
|
+
handleClick() { }
|
|
34
|
+
}
|
|
35
|
+
LoadingWidget.defaultProps = {
|
|
36
|
+
...Widget.defaultProps,
|
|
37
|
+
id: 'loading',
|
|
38
|
+
placement: 'top-left',
|
|
39
|
+
label: 'Loading layer data'
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=loading-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-widget.js","sourceRoot":"","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pB,CAAC;IACH,CAAC;IAED,0DAA0D;IAC1D,WAAW,KAAI,CAAC;;AA5CT,0BAAY,GAAiC;IAClD,GAAG,MAAM,CAAC,YAAY;IACtB,EAAE,EAAE,SAAS;IACb,SAAS,EAAE,UAAU;IACrB,KAAK,EAAE,oBAAoB;CAC5B,AALkB,CAKjB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { WidgetPlacement } from '@deck.gl/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Widget, WidgetProps } from '@deck.gl/core';
|
|
3
3
|
/** @todo - is the the best we can do? */
|
|
4
4
|
type ViewState = Record<string, unknown>;
|
|
5
5
|
/** Properties for the ResetViewWidget */
|
|
6
|
-
export type ResetViewWidgetProps =
|
|
6
|
+
export type ResetViewWidgetProps = WidgetProps & {
|
|
7
7
|
/** Widget positioning within the view. Default 'top-left'. */
|
|
8
8
|
placement?: WidgetPlacement;
|
|
9
9
|
/** Tooltip message */
|
|
@@ -16,13 +16,13 @@ export type ResetViewWidgetProps = WidgetImplProps & {
|
|
|
16
16
|
/**
|
|
17
17
|
* A button widget that resets the view state of deck to an initial state.
|
|
18
18
|
*/
|
|
19
|
-
export declare class ResetViewWidget extends
|
|
19
|
+
export declare class ResetViewWidget extends Widget<ResetViewWidgetProps> {
|
|
20
20
|
static defaultProps: Required<ResetViewWidgetProps>;
|
|
21
21
|
className: string;
|
|
22
22
|
placement: WidgetPlacement;
|
|
23
23
|
constructor(props?: ResetViewWidgetProps);
|
|
24
24
|
setProps(props: Partial<ResetViewWidgetProps>): void;
|
|
25
|
-
onRenderHTML(): void;
|
|
25
|
+
onRenderHTML(rootElement: HTMLElement): void;
|
|
26
26
|
handleClick(): void;
|
|
27
27
|
setViewState(viewState: ViewState): void;
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-view-widget.d.ts","sourceRoot":"","sources":["../src/reset-view-widget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reset-view-widget.d.ts","sourceRoot":"","sources":["../src/reset-view-widget.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAGlD,yCAAyC;AACzC,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzC,yCAAyC;AACzC,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAC/C,8DAA8D;IAC9D,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,SAAQ,MAAM,CAAC,oBAAoB,CAAC;IAC/D,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAOjD;IAEF,SAAS,SAA4B;IACrC,SAAS,EAAE,eAAe,CAAc;gBAE5B,KAAK,GAAE,oBAAyB;IAK5C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAK7C,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAW5C,WAAW;IAKX,YAAY,CAAC,SAAS,EAAE,SAAS;CAWlC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
2
|
import { render } from 'preact';
|
|
3
|
-
import {
|
|
4
|
-
import { IconButton } from "./components.js";
|
|
3
|
+
import { Widget } from '@deck.gl/core';
|
|
4
|
+
import { IconButton } from "./lib/components/icon-button.js";
|
|
5
5
|
/**
|
|
6
6
|
* A button widget that resets the view state of deck to an initial state.
|
|
7
7
|
*/
|
|
8
|
-
export class ResetViewWidget extends
|
|
8
|
+
export class ResetViewWidget extends Widget {
|
|
9
9
|
constructor(props = {}) {
|
|
10
|
-
super(
|
|
10
|
+
super(props, ResetViewWidget.defaultProps);
|
|
11
11
|
this.className = 'deck-widget-reset-view';
|
|
12
12
|
this.placement = 'top-left';
|
|
13
13
|
this.placement = props.placement ?? this.placement;
|
|
@@ -16,11 +16,8 @@ export class ResetViewWidget extends WidgetImpl {
|
|
|
16
16
|
this.placement = props.placement ?? this.placement;
|
|
17
17
|
super.setProps(props);
|
|
18
18
|
}
|
|
19
|
-
onRenderHTML() {
|
|
20
|
-
|
|
21
|
-
if (!element)
|
|
22
|
-
return;
|
|
23
|
-
render(_jsx(IconButton, { className: "deck-widget-reset-focus", label: this.props.label, onClick: this.handleClick.bind(this) }), element);
|
|
19
|
+
onRenderHTML(rootElement) {
|
|
20
|
+
render(_jsx(IconButton, { className: "deck-widget-reset-focus", label: this.props.label, onClick: this.handleClick.bind(this) }), rootElement);
|
|
24
21
|
}
|
|
25
22
|
handleClick() {
|
|
26
23
|
const initialViewState = this.props.initialViewState || this.deck?.props.initialViewState;
|
|
@@ -39,7 +36,7 @@ export class ResetViewWidget extends WidgetImpl {
|
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
ResetViewWidget.defaultProps = {
|
|
42
|
-
...
|
|
39
|
+
...Widget.defaultProps,
|
|
43
40
|
id: 'reset-view',
|
|
44
41
|
placement: 'top-left',
|
|
45
42
|
label: 'Reset View',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-view-widget.js","sourceRoot":"","sources":["../src/reset-view-widget.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"reset-view-widget.js","sourceRoot":"","sources":["../src/reset-view-widget.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAc,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,UAAU,EA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E,EAAE,EAAC,CAAC,CAAC;IACzF,CAAC;;AAhDM,4BAAY,GAAmC;IACpD,GAAG,MAAM,CAAC,YAAY;IACtB,EAAE,EAAE,YAAY;IAChB,SAAS,EAAE,UAAU;IACrB,KAAK,EAAE,YAAY;IACnB,gBAAgB,EAAE,SAAU;IAC5B,MAAM,EAAE,SAAU;CACnB,AAPkB,CAOjB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { WidgetPlacement, Viewport } from '@deck.gl/core';
|
|
2
|
+
import { Widget, WidgetProps } from '@deck.gl/core';
|
|
3
|
+
export type ScaleWidgetProps = WidgetProps & {
|
|
4
|
+
placement?: WidgetPlacement;
|
|
5
|
+
label?: string;
|
|
6
|
+
onCapture?: (widget: ScaleWidget) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A scale widget that displays a Google Maps–like scale indicator.
|
|
10
|
+
* Instead of text inside a div, this widget renders an SVG that contains a horizontal line
|
|
11
|
+
* with two vertical tick marks (extending upward from the line only) and a pretty distance label
|
|
12
|
+
* positioned to the left of the line. The horizontal line’s length is computed from a “nice”
|
|
13
|
+
* candidate distance (e.g. 200, 500, 1000 m, etc.) so that its pixel width is between 100 and 200.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ScaleWidget extends Widget<ScaleWidgetProps> {
|
|
16
|
+
static defaultProps: Required<ScaleWidgetProps>;
|
|
17
|
+
className: string;
|
|
18
|
+
placement: WidgetPlacement;
|
|
19
|
+
scaleWidth: number;
|
|
20
|
+
scaleValue: number;
|
|
21
|
+
scaleText: string;
|
|
22
|
+
constructor(props?: ScaleWidgetProps);
|
|
23
|
+
setProps(props: Partial<ScaleWidgetProps>): void;
|
|
24
|
+
onRenderHTML(rootElement: HTMLElement): void;
|
|
25
|
+
onViewportChange(viewport: Viewport): void;
|
|
26
|
+
handleClick(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=scale-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale-widget.d.ts","sourceRoot":"","sources":["../src/scale-widget.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC3C,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,MAAM,CAAC,gBAAgB,CAAC;IACvD,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAM7C;IAEF,SAAS,SAAuB;IAChC,SAAS,EAAE,eAAe,CAAiB;IAG3C,UAAU,EAAE,MAAM,CAAM;IAExB,UAAU,EAAE,MAAM,CAAK;IAEvB,SAAS,EAAE,MAAM,CAAM;gBAEX,KAAK,GAAE,gBAAqB;IAKxC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAKhD,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAwD5C,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAmB1C,WAAW,IAAI,IAAI;CACpB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { render } from 'preact';
|
|
3
|
+
import { Widget } from '@deck.gl/core';
|
|
4
|
+
/**
|
|
5
|
+
* A scale widget that displays a Google Maps–like scale indicator.
|
|
6
|
+
* Instead of text inside a div, this widget renders an SVG that contains a horizontal line
|
|
7
|
+
* with two vertical tick marks (extending upward from the line only) and a pretty distance label
|
|
8
|
+
* positioned to the left of the line. The horizontal line’s length is computed from a “nice”
|
|
9
|
+
* candidate distance (e.g. 200, 500, 1000 m, etc.) so that its pixel width is between 100 and 200.
|
|
10
|
+
*/
|
|
11
|
+
export class ScaleWidget extends Widget {
|
|
12
|
+
constructor(props = {}) {
|
|
13
|
+
super(props, ScaleWidget.defaultProps);
|
|
14
|
+
this.className = 'deck-widget-scale';
|
|
15
|
+
this.placement = 'bottom-left';
|
|
16
|
+
// The pixel width of the scale line (computed from a candidate distance)
|
|
17
|
+
this.scaleWidth = 10;
|
|
18
|
+
// The candidate distance (in meters) corresponding to the scale line length.
|
|
19
|
+
this.scaleValue = 0;
|
|
20
|
+
// The formatted distance label (e.g. "200 m" or "1.0 km")
|
|
21
|
+
this.scaleText = '';
|
|
22
|
+
this.placement = props.placement ?? this.placement;
|
|
23
|
+
}
|
|
24
|
+
setProps(props) {
|
|
25
|
+
this.placement = props.placement ?? this.placement;
|
|
26
|
+
super.setProps(props);
|
|
27
|
+
}
|
|
28
|
+
onRenderHTML(rootElement) {
|
|
29
|
+
// Reserve space for the text label (to the left of the horizontal line)
|
|
30
|
+
const lineOffsetX = 50;
|
|
31
|
+
// Overall SVG width includes the left offset plus the computed scale line width.
|
|
32
|
+
const svgWidth = lineOffsetX + this.scaleWidth;
|
|
33
|
+
const tickHeight = 10; // vertical tick extends upward by 10 pixels from the horizontal line
|
|
34
|
+
render(_jsxs("svg", { className: "deck-widget-scale", width: svgWidth, height: 30, style: { overflow: 'visible', background: 'transparent' }, onClick: this.handleClick.bind(this), children: [_jsx("text", { x: lineOffsetX + 5, y: "10", textAnchor: "end", alignmentBaseline: "middle", style: { fontSize: '16px', fill: 'black', fontWeight: 'bold', fontFamily: 'sans-serif' }, children: this.scaleText }), _jsx("line", { x1: lineOffsetX, y1: "15", x2: lineOffsetX + this.scaleWidth, y2: "15", stroke: "black", strokeWidth: "6" }), _jsx("line", { x1: lineOffsetX, y1: "15", x2: lineOffsetX, y2: 15 - tickHeight, stroke: "black", strokeWidth: "6" }), _jsx("line", { x1: lineOffsetX + this.scaleWidth, y1: "15", x2: lineOffsetX + this.scaleWidth, y2: 15 - tickHeight, stroke: "black", strokeWidth: "6" })] }), rootElement);
|
|
35
|
+
}
|
|
36
|
+
onViewportChange(viewport) {
|
|
37
|
+
// Only handle geospatial viewports (which contain latitude)
|
|
38
|
+
if (!('latitude' in viewport))
|
|
39
|
+
return;
|
|
40
|
+
const { latitude, zoom } = viewport;
|
|
41
|
+
const metersPerPixel = getMetersPerPixel(latitude, zoom);
|
|
42
|
+
const { candidate, candidatePixels } = computeScaleCandidate(metersPerPixel);
|
|
43
|
+
this.scaleValue = candidate;
|
|
44
|
+
this.scaleWidth = candidatePixels;
|
|
45
|
+
// Format the candidate distance for display (using km if >= 1000 m)
|
|
46
|
+
if (candidate >= 1000) {
|
|
47
|
+
this.scaleText = `${(candidate / 1000).toFixed(1)} km`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.scaleText = `${candidate} m`;
|
|
51
|
+
}
|
|
52
|
+
this.updateHTML();
|
|
53
|
+
}
|
|
54
|
+
handleClick() { }
|
|
55
|
+
}
|
|
56
|
+
ScaleWidget.defaultProps = {
|
|
57
|
+
...Widget.defaultProps,
|
|
58
|
+
id: 'scale',
|
|
59
|
+
placement: 'bottom-left',
|
|
60
|
+
label: 'Scale',
|
|
61
|
+
onCapture: undefined
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Compute the meters per pixel at a given latitude and zoom level.
|
|
65
|
+
*
|
|
66
|
+
* @param latitude - The current latitude.
|
|
67
|
+
* @param zoom - The current zoom level.
|
|
68
|
+
* @returns The number of meters per pixel.
|
|
69
|
+
*/
|
|
70
|
+
function getMetersPerPixel(latitude, zoom) {
|
|
71
|
+
const earthCircumference = 40075016.686;
|
|
72
|
+
return (earthCircumference * Math.cos((latitude * Math.PI) / 180)) / Math.pow(2, zoom + 8);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compute a "nice" scale candidate such that the scale bar width in pixels is between 100 and 200.
|
|
76
|
+
* The candidate distance (in meters) will be one of a set of round numbers (100, 200, 500, 1000, 2000, 5000, etc.).
|
|
77
|
+
*
|
|
78
|
+
* @param metersPerPixel - The number of meters per pixel at the current zoom/latitude.
|
|
79
|
+
* @returns An object containing the candidate distance and its width in pixels.
|
|
80
|
+
*/
|
|
81
|
+
function computeScaleCandidate(metersPerPixel) {
|
|
82
|
+
const minPixels = 100;
|
|
83
|
+
const maxPixels = 200;
|
|
84
|
+
const targetPixels = (minPixels + maxPixels) / 2;
|
|
85
|
+
const targetDistance = targetPixels * metersPerPixel;
|
|
86
|
+
const exponent = Math.floor(Math.log10(targetDistance));
|
|
87
|
+
const base = Math.pow(10, exponent);
|
|
88
|
+
const multipliers = [1, 2, 5];
|
|
89
|
+
let candidate = multipliers[0] * base;
|
|
90
|
+
let candidatePixels = candidate / metersPerPixel;
|
|
91
|
+
for (let i = 0; i < multipliers.length; i++) {
|
|
92
|
+
const currentCandidate = multipliers[i] * base;
|
|
93
|
+
const currentPixels = currentCandidate / metersPerPixel;
|
|
94
|
+
if (currentPixels >= minPixels && currentPixels <= maxPixels) {
|
|
95
|
+
candidate = currentCandidate;
|
|
96
|
+
candidatePixels = currentPixels;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (currentPixels > maxPixels) {
|
|
100
|
+
candidate = i > 0 ? multipliers[i - 1] * base : currentCandidate;
|
|
101
|
+
candidatePixels = candidate / metersPerPixel;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (i === multipliers.length - 1 && currentPixels < minPixels) {
|
|
105
|
+
candidate = multipliers[0] * base * 10;
|
|
106
|
+
candidatePixels = candidate / metersPerPixel;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { candidate, candidatePixels };
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=scale-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale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C,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9B,IAAI,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACtC,IAAI,eAAe,GAAG,SAAS,GAAG,cAAc,CAAC;IAEjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC/C,MAAM,aAAa,GAAG,gBAAgB,GAAG,cAAc,CAAC;QACxD,IAAI,aAAa,IAAI,SAAS,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;YAC7D,SAAS,GAAG,gBAAgB,CAAC;YAC7B,eAAe,GAAG,aAAa,CAAC;YAChC,MAAM;QACR,CAAC;QACD,IAAI,aAAa,GAAG,SAAS,EAAE,CAAC;YAC9B,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;YACjE,eAAe,GAAG,SAAS,GAAG,cAAc,CAAC;YAC7C,MAAM;QACR,CAAC;QACD,IAAI,CAAC,KAAK,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,GAAG,SAAS,EAAE,CAAC;YAC9D,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;YACvC,eAAe,GAAG,SAAS,GAAG,cAAc,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WidgetImpl, WidgetImplProps } from "./widget-impl.js";
|
|
2
1
|
import type { WidgetPlacement } from '@deck.gl/core';
|
|
2
|
+
import { Widget, WidgetProps } from '@deck.gl/core';
|
|
3
3
|
/** Properties for the ScreenshotWidget */
|
|
4
|
-
export type ScreenshotWidgetProps =
|
|
4
|
+
export type ScreenshotWidgetProps = WidgetProps & {
|
|
5
5
|
/** Widget positioning within the view. Default 'top-left'. */
|
|
6
6
|
placement?: WidgetPlacement;
|
|
7
7
|
/** Tooltip message */
|
|
@@ -17,13 +17,13 @@ export type ScreenshotWidgetProps = WidgetImplProps & {
|
|
|
17
17
|
* A button widget that captures a screenshot of the current canvas and downloads it as a (png) file.
|
|
18
18
|
* @note only captures canvas contents, not HTML DOM or CSS styles
|
|
19
19
|
*/
|
|
20
|
-
export declare class ScreenshotWidget extends
|
|
20
|
+
export declare class ScreenshotWidget extends Widget<ScreenshotWidgetProps> {
|
|
21
21
|
static defaultProps: Required<ScreenshotWidgetProps>;
|
|
22
22
|
className: string;
|
|
23
23
|
placement: WidgetPlacement;
|
|
24
24
|
constructor(props?: ScreenshotWidgetProps);
|
|
25
25
|
setProps(props: Partial<ScreenshotWidgetProps>): void;
|
|
26
|
-
onRenderHTML(): void;
|
|
26
|
+
onRenderHTML(rootElement: HTMLElement): void;
|
|
27
27
|
handleClick(): void;
|
|
28
28
|
/** @note only captures canvas contents, not HTML DOM or CSS styles */
|
|
29
29
|
captureScreenToDataURL(imageFormat: string): string | undefined;
|