<script src="https://cdn.jsdelivr.net/npm/ol@9.1.0/dist/ol.js"></script>
<link href="https://cdn.jsdelivr.net/npm/ol@9.1.0/ol.min.css" rel="stylesheet">
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
@php
$latitude = $getLatitude();
$longitude = $getLongitude();
$height = $getHeight() . "px";
$zoom = $getZoom();
@endphp
<div
x-data="{state: $wire.entangle('{{ $getStatePath() }}')}"
x-init="
const map = new ol.Map({
target: $refs.map,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([{{ $longitude }}, {{ $latitude }}]),
zoom: {{ $zoom }}
})
});
map.on('singleclick', (event) => {
const coords = ol.proj.toLonLat(event.coordinate);
const [lat, lng] = coords;
state = {lat, lng};
$wire.set('latitude', lat);
$wire.set('longitude', lng);
});
"
wire:ignore
>
<div x-ref="map"
class="w-full"
style="
height: {{ $height }};
min-height: 30vh;
z-index: 1 !important;
"
>
</div>
</div>
</x-dynamic-component>
<script src="https://cdn.jsdelivr.net/npm/ol@9.1.0/dist/ol.js"></script>
<link href="https://cdn.jsdelivr.net/npm/ol@9.1.0/ol.min.css" rel="stylesheet">
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
@php
$latitude = $getLatitude();
$longitude = $getLongitude();
$height = $getHeight() . "px";
$zoom = $getZoom();
@endphp
<div
x-data="{state: $wire.entangle('{{ $getStatePath() }}')}"
x-init="
const map = new ol.Map({
target: $refs.map,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([{{ $longitude }}, {{ $latitude }}]),
zoom: {{ $zoom }}
})
});
map.on('singleclick', (event) => {
const coords = ol.proj.toLonLat(event.coordinate);
const [lat, lng] = coords;
state = {lat, lng};
$wire.set('latitude', lat);
$wire.set('longitude', lng);
});
"
wire:ignore
>
<div x-ref="map"
class="w-full"
style="
height: {{ $height }};
min-height: 30vh;
z-index: 1 !important;
"
>
</div>
</div>
</x-dynamic-component>