✨ Parse Plus Code in latitude input
This commit is contained in:
parent
032ee8ed11
commit
25cf9128fc
@ -26,6 +26,12 @@ Supported formats include examples like:
|
||||
- `37°46'29.64" N, 122°25'9.84" W`
|
||||
- `37°46.494' N, 122°25.164' W`
|
||||
|
||||
### Plus Code Parsing
|
||||
|
||||
You can paste a [Plus Code](https://maps.google.com/pluscodes/) into the `latitude` input when creating a Place.
|
||||
|
||||
Example: `849VCWC8+R9`
|
||||
|
||||
## Trip
|
||||
|
||||
### Display a day itinerary
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
"leaflet": "^1.9.4",
|
||||
"@types/leaflet": "^1.9.19",
|
||||
"@types/leaflet.markercluster": "^1.5.5",
|
||||
"open-location-code-typescript": "^1.5.0",
|
||||
"leaflet-contextmenu": "^1.4.0",
|
||||
"leaflet-ant-path": "1.3.0",
|
||||
"leaflet.markercluster": "^1.5.3",
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import OpenLocationCode from "open-location-code-typescript";
|
||||
|
||||
const patternDEC = /^\s*(-?\d{1,3}(?:\.\d+)?)\s*,\s*(-?\d{1,3}(?:\.\d+)?)\s*$/;
|
||||
const patternDD =
|
||||
/^\s*(\d{1,3}(?:\.\d+)?)°?\s*([NS])\s*,\s*(\d{1,3}(?:\.\d+)?)°?\s*([EW])\s*$/i;
|
||||
@ -33,6 +35,12 @@ export function checkAndParseLatLng(
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse PlusCode
|
||||
if (OpenLocationCode.isValid(value)) {
|
||||
const result = OpenLocationCode.decode(value);
|
||||
return [result.latitudeCenter, result.longitudeCenter];
|
||||
}
|
||||
|
||||
// Parse DMS, DD, DDM to decimal [Lat, Lng]
|
||||
const dec = value.match(patternDEC);
|
||||
if (dec) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user