|
|
@ -11,6 +11,7 @@ import { Controller } from '@hotwired/stimulus'; |
|
|
|
import 'leaflet'; |
|
|
|
|
|
|
|
export default class extends Controller { |
|
|
|
static targets = [ 'openLink' ]; |
|
|
|
static values = { |
|
|
|
geojson: String, |
|
|
|
overpassResult: String, |
|
|
@ -19,6 +20,8 @@ export default class extends Controller { |
|
|
|
} |
|
|
|
|
|
|
|
connect() { |
|
|
|
const self = this; |
|
|
|
|
|
|
|
// Constitue une collection d’icones aux couleurs Bootstrap
|
|
|
|
const iconHtml = `
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" class="bi bi-geo-alt-fill" viewBox="0 0 16 16"> |
|
|
@ -41,6 +44,14 @@ export default class extends Controller { |
|
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' |
|
|
|
}).addTo(map); |
|
|
|
|
|
|
|
// Suit les mouvements de la carte
|
|
|
|
map.on('moveend', function() { |
|
|
|
var center = map.getCenter(); |
|
|
|
var lat = center.lat; |
|
|
|
var lng = center.lng; |
|
|
|
self.openLinkTarget.setAttribute('href', `geo:${lat},${lng}`); |
|
|
|
}); |
|
|
|
|
|
|
|
// Crée un ensemble de couches pour mieux les manipuler
|
|
|
|
// individuellement
|
|
|
|
var layer = L.featureGroup(); |
|
|
|