Sha256: 8dde6d03e7db738ef94e99ebc337c67699c9a130626763a2375e6cbaaa5741e8
Contents?: true
Size: 1.14 KB
Versions: 22
Compression:
Stored size: 1.14 KB
Contents
import * as L from "leaflet"; import MapController from "src/decidim/map/controller" import "src/decidim/vendor/leaflet-tilelayer-here" export default class MapDragMarkerController extends MapController { start() { if (this.config.marker) { this.addMarker(this.config.marker); } else { this.map.fitWorld(); } } addMarker(markerData) { if (markerData.latitude === null || markerData.longitude === null) { return; } const coordinates = { lat: markerData.latitude, lng: markerData.longitude }; this.triggerEvent("coordinates", [coordinates]); this.marker = L.marker(coordinates, { icon: this.createIcon(), keyboard: true, title: markerData.title, draggable: true }); this.marker.on("drag", (ev) => { this.triggerEvent("coordinates", [ev.target.getLatLng()]); }); this.marker.addTo(this.map); const zoom = parseInt(this.config.zoom, 10) || 14; this.map.setView(coordinates, zoom); } getMarker() { return this.marker; } removeMarker() { if (this.marker) { this.marker.remove(); this.marker = null; } } }
Version data entries
22 entries across 22 versions & 1 rubygems