feat: extract fuel.map component and wire Leaflet to map-update browser event
This commit is contained in:
@@ -65,11 +65,13 @@ export function stationMap(results, meta, radius) {
|
||||
maxZoom: 19,
|
||||
}).addTo(this._map);
|
||||
|
||||
if (this.results && this.results.length > 0) {
|
||||
window.addEventListener('map-update', (e) => {
|
||||
this.results = e.detail.results;
|
||||
this.meta = e.detail.meta;
|
||||
this.radius = e.detail.radius;
|
||||
this._plotMarkers();
|
||||
}
|
||||
});
|
||||
|
||||
this.$watch('results', () => this._plotMarkers());
|
||||
this.locateUser();
|
||||
},
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
@props(['results' => []])
|
||||
|
||||
<div
|
||||
x-data="stationMap(@entangle('results'), @entangle('meta'), @entangle('radius'))"
|
||||
class="h-56 w-full overflow-hidden border-y border-[#e5ded7] md:h-96"
|
||||
x-data="stationMap([], {}, 5)"
|
||||
class="h-56 w-full overflow-hidden border-y border-border md:h-96"
|
||||
></div>
|
||||
|
||||
3
resources/views/livewire/public/fuel/map.blade.php
Normal file
3
resources/views/livewire/public/fuel/map.blade.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="mb-4" wire:ignore>
|
||||
<x-fuel.station-map />
|
||||
</div>
|
||||
Reference in New Issue
Block a user