From 5aa8b912afe057c2603d2a815ed14d5cfe419c6a Mon Sep 17 00:00:00 2001 From: Benjamin Takats Date: Sat, 28 Jan 2023 21:56:04 +0100 Subject: [PATCH] osm data --- .../Livewire/Meetup/PrepareForBtcMapItem.php | 11 +++++++- .../meetup/prepare-for-btc-map-item.blade.php | 25 ++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/Meetup/PrepareForBtcMapItem.php b/app/Http/Livewire/Meetup/PrepareForBtcMapItem.php index 6b8f71e0..7fe09df1 100644 --- a/app/Http/Livewire/Meetup/PrepareForBtcMapItem.php +++ b/app/Http/Livewire/Meetup/PrepareForBtcMapItem.php @@ -14,6 +14,7 @@ class PrepareForBtcMapItem extends Component public $wikipediaSearchResults; public $osmSearchResults; public $osmSearchResultsState; + public $osmSearchResultsCountry; public $selectedItem; @@ -31,6 +32,12 @@ class PrepareForBtcMapItem extends Component ); $this->osmSearchResultsState = $response->json(); + $response = Http::acceptJson() + ->get( + 'https://nominatim.openstreetmap.org/search?country='.$this->meetup->city->name.'&format=json&polygon_geojson=1' + ); + $this->osmSearchResultsCountry = $response->json(); + if ($this->meetup->city->osm_relation) { $this->selectedItem = $this->meetup->city->osm_relation; @@ -43,10 +50,12 @@ class PrepareForBtcMapItem extends Component } } - public function selectItem($index, bool $isState = false) + public function selectItem($index, bool $isState = false, $isCountry = false) { if ($isState) { $this->selectedItem = $this->osmSearchResultsState[$index]; + } elseif ($isCountry) { + $this->selectedItem = $this->osmSearchResultsCountry[$index]; } else { $this->selectedItem = $this->osmSearchResults[$index]; } diff --git a/resources/views/livewire/meetup/prepare-for-btc-map-item.blade.php b/resources/views/livewire/meetup/prepare-for-btc-map-item.blade.php index ffddf964..d8ee7876 100644 --- a/resources/views/livewire/meetup/prepare-for-btc-map-item.blade.php +++ b/resources/views/livewire/meetup/prepare-for-btc-map-item.blade.php @@ -2,14 +2,15 @@
Zurück -
+

Search city: {{ $meetup->city->name }}

OSM API Response

@foreach($osmSearchResults as $item) -
+
{{ $item['display_name'] }}
@@ -22,7 +23,22 @@
@foreach($osmSearchResultsState as $item) -
+
+ {{ $item['display_name'] }} +
+
+ @endforeach +
+
+
+

Search country: {{ $meetup->city->name }}

+

OSM API Response

+
+ @foreach($osmSearchResultsCountry as $item) + +
{{ $item['display_name'] }}
@@ -88,7 +104,8 @@

Wikipedia Search Results

@foreach($wikipediaSearchResults['results']['bindings'] ?? [] as $pop) -
+
population: {{ number_format($pop['population']['value']) }}
@endforeach