Villa San Michele

This commit is contained in:
Nicolò P 2024-12-01 10:32:01 +01:00
parent 1393b779ff
commit 0cb1f7a32d
7 changed files with 16 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 KiB

View File

@ -112,7 +112,7 @@
</a>
</li>
<li>
<a class="button" title="Vai al sito San Michele" data-action="marker#go" data-coords="">
<a class="button" title="Vai al sito San Michele" data-action="marker#go" data-coords="40.557380 14.225806">
Villa San Michele
</a>
</li>

View File

@ -11,27 +11,31 @@ export default class extends Controller {
go(event) {
let map = window.LMap;
const coords = event.currentTarget.getAttribute('data-coords').split(' ');
const coords = event.currentTarget
.getAttribute('data-coords').split(' ');
let marker = this.getMarker(map, coords);
marker?.openTooltip();
map.setView(
coords,
this.END_ZOOM,
this.mapAnimate
);
let marker = this.getMarker(map, coords);
marker.openTooltip();
}
/**
* @param {L.Map} map
* @param {Array<String>} coords
* @returns {L.Marker}
*/
getMarker(map, coords) {
let marker;
map.eachLayer(l => {
if (l instanceof L.Marker) {
const latLng = l.getLatLng();
const lat = latLng['lat'];
const lng = latLng['lng'];
map.eachLayer(layer => {
if (layer instanceof L.Marker) {
const latLng = layer.getLatLng();
const {lat, lng} = latLng;
if (lat === Number(coords[0]) && lng === Number(coords[1])) {
marker = l;
marker = layer;
return;
}
}