Sha256: 079c51a3b9a4b6595d169eeb4303adce2f33255d2708cb5f89ae9509de02d4de
Contents?: true
Size: 1.49 KB
Versions: 6
Compression:
Stored size: 1.49 KB
Contents
import attachGeocoding from "src/decidim/geocoding/attach_input" import getCoordinateInputName from "src/decidim/geocoding/coordinate_input"; $(() => { const $map = $("#address_map"); const $addressInputField = $("[data-decidim-geocoding]"); if ($map.length) { if (!$addressInputField.data("coordinates")) { $map.hide(); } $addressInputField.on("geocoder-suggest-coordinates.decidim", () => $map.show()); const markerAddedAnnouncement = $addressInputField.data("screen-reader-announcement"); let latFieldName = "latitude"; let longFieldName = "longitude"; if ($addressInputField.length > 0) { latFieldName = getCoordinateInputName("latitude", $addressInputField, {}) longFieldName = getCoordinateInputName("longitude", $addressInputField, {}) } $("[data-decidim-map]").on("ready.decidim", (event) => { const ctrl = $(event.target).data("map-controller"); ctrl.setEventHandler("coordinates", (ev) => { $(`input[name='${latFieldName}']`).val(ev.lat); $(`input[name='${longFieldName}']`).val(ev.lng); }); attachGeocoding($addressInputField, null, (coordinates) => { // Remove previous marker when user updates address in address field ctrl.removeMarker(); ctrl.addMarker({ latitude: coordinates[0], longitude: coordinates[1], address: $addressInputField.val() }); window.Decidim.announceForScreenReader(markerAddedAnnouncement); }); }); } });
Version data entries
6 entries across 6 versions & 1 rubygems