From e9b9a5a18e8a832885569d57f6af678585bdbfda Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Tue, 13 Aug 2024 18:15:58 +0200 Subject: [PATCH 1/2] New LefletMap component --- src/components/LeafletMap.vue | 74 +++++++++++++++++++++++++++++++++++ src/utils.js | 36 +++++++++++++---- 2 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 src/components/LeafletMap.vue diff --git a/src/components/LeafletMap.vue b/src/components/LeafletMap.vue new file mode 100644 index 0000000000..ccc2a1cc82 --- /dev/null +++ b/src/components/LeafletMap.vue @@ -0,0 +1,74 @@ + + + diff --git a/src/utils.js b/src/utils.js index 825d288585..0dcdb02687 100644 --- a/src/utils.js +++ b/src/utils.js @@ -269,20 +269,40 @@ function getLocationLatLng(locationObject) { else if (locationObject.geometry && locationObject.geometry.coordinates) { return [locationObject.geometry.coordinates[1], locationObject.geometry.coordinates[0]] } + // OP return [locationObject.osm_lat, locationObject.osm_lon] } -function getMapBounds(results, source='nominatim') { - if (source === 'photon') { - return results.map(l => [l.geometry.coordinates[1], l.geometry.coordinates[0]]) +function getMapBounds(results) { + if (results.length > 0) { + // Nominatim + if (results[0].lat && results[0].lon) { + return results.map(l => [l.lat, l.lon]) + } + // Photon + else if (results[0].geometry && results[0].geometry.coordinates) { + return results.map(l => [l.geometry.coordinates[1], l.geometry.coordinates[0]]) + } + // OP + return results.map(l => [l.osm_lat, l.osm_lon]) } - return results.map(l => [l.lat, l.lon]) + return null } -function getMapCenter(results, source='nominatim') { - if (source === 'photon') { - return [results[0].geometry.coordinates[1], results[0].geometry.coordinates[0]] + +function getMapCenter(results) { + if (results.length > 0) { + // Nominatim + if (results[0].lat && results[0].lon) { + return [results[0].lat, results[0].lon] + } + // Photon + else if (results[0].geometry && results[0].geometry.coordinates) { + return [results[0].geometry.coordinates[1], results[0].geometry.coordinates[0]] + } + // OP + return [results[0].osm_lat, results[0].osm_lon] } - return [results[0].lat, results[0].lon] + results [45, 5] } From f91e312abdde329544fb6c4cde4a7e0d64f45230 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 14 Aug 2024 10:52:11 +0200 Subject: [PATCH 2/2] Integrate in LocationSelectorDialog component --- src/components/LocationSelectorDialog.vue | 53 +++-------------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/src/components/LocationSelectorDialog.vue b/src/components/LocationSelectorDialog.vue index ca2553bc37..cc0b29e4f1 100644 --- a/src/components/LocationSelectorDialog.vue +++ b/src/components/LocationSelectorDialog.vue @@ -59,19 +59,8 @@ - - - - - -

{{ getLocationTitle(location, true, false, false) }}

- {{ getLocationTitle(location, false, true, true) }}
- - {{ getLocationTag(location) }} - -
-
-
+ + @@ -126,8 +115,6 @@