@defra/forms-engine-plugin 4.5.2 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/.public/javascripts/shared.min.js +1 -1
  2. package/.public/javascripts/shared.min.js.map +1 -1
  3. package/.server/client/javascripts/geospatial-map.js +4 -4
  4. package/.server/client/javascripts/geospatial-map.js.map +1 -1
  5. package/.server/client/javascripts/location-map.js +3 -3
  6. package/.server/client/javascripts/location-map.js.map +1 -1
  7. package/.server/client/javascripts/map.d.ts +6 -0
  8. package/.server/client/javascripts/map.js +13 -0
  9. package/.server/client/javascripts/map.js.map +1 -1
  10. package/.server/server/plugins/engine/components/FileUploadField.js +1 -1
  11. package/.server/server/plugins/engine/components/FileUploadField.js.map +1 -1
  12. package/.server/server/plugins/engine/components/GeospatialField.js +1 -0
  13. package/.server/server/plugins/engine/components/GeospatialField.js.map +1 -1
  14. package/.server/server/plugins/engine/components/helpers/geospatial.js +1 -1
  15. package/.server/server/plugins/engine/components/helpers/geospatial.js.map +1 -1
  16. package/.server/server/plugins/engine/components/helpers/geospatial.test.js +6 -1
  17. package/.server/server/plugins/engine/components/helpers/geospatial.test.js.map +1 -1
  18. package/package.json +2 -2
  19. package/src/client/javascripts/geospatial-map.js +4 -4
  20. package/src/client/javascripts/location-map.js +3 -3
  21. package/src/client/javascripts/map.js +13 -0
  22. package/src/server/plugins/engine/components/FileUploadField.ts +1 -1
  23. package/src/server/plugins/engine/components/GeospatialField.test.ts +2 -2
  24. package/src/server/plugins/engine/components/GeospatialField.ts +2 -0
  25. package/src/server/plugins/engine/components/helpers/geospatial.test.js +8 -1
  26. package/src/server/plugins/engine/components/helpers/geospatial.ts +1 -1
@@ -4,19 +4,19 @@ const helpPanelConfig = {
4
4
  showLabel: true,
5
5
  label: 'How to use this map',
6
6
  mobile: {
7
- slot: 'bottom',
7
+ slot: 'drawer',
8
8
  open: true,
9
9
  dismissible: true,
10
10
  modal: false
11
11
  },
12
12
  tablet: {
13
- slot: 'bottom',
13
+ slot: 'drawer',
14
14
  open: true,
15
15
  dismissible: true,
16
16
  modal: false
17
17
  },
18
18
  desktop: {
19
- slot: 'bottom',
19
+ slot: 'drawer',
20
20
  open: true,
21
21
  dismissible: true,
22
22
  modal: false
@@ -229,7 +229,7 @@ function createFeatureHTML(feature, index, mapId, readonly) {
229
229
  <dd class="govuk-summary-list__value">${typeDescriptions[feature.geometry.type]}</dd>
230
230
  </div>
231
231
  <div class="govuk-summary-list__row">
232
- <dt class="govuk-summary-list__key">Center grid reference</dt>
232
+ <dt class="govuk-summary-list__key">Centre grid reference</dt>
233
233
  <dd class="govuk-summary-list__value">${feature.properties.centroidGridReference}</dd>
234
234
  </div>
235
235
  <div class="govuk-summary-list__row">
@@ -1 +1 @@
1
- {"version":3,"file":"geospatial-map.js","names":["bbox","EVENTS","createMap","defaultConfig","getCentroidGridRef","getCoordinateGridRef","helpPanelConfig","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","html","lineFeatureProperties","stroke","fill","strokeWidth","polygonFeatureProperties","typeDescriptions","Point","LineString","Polygon","POINT_SVG","POLYGON_SVG","LINE_SVG","getGeoJSON","geospatialInput","value","trim","hasValue","features","JSON","parse","geojson","type","getBoundingBox","processGeospatial","config","geospatial","index","defra","window","HTMLDivElement","querySelector","HTMLTextAreaElement","listEl","mapId","createContainers","bounds","length","undefined","drawPlugin","drawMLPlugin","initConfig","plugins","map","interactPlugin","featuresManager","getFeaturesManager","activeFeatureManager","getActiveFeatureManager","uiManager","getUIManager","context","addEventListeners","addFeatureToMap","feature","geometry","addFeature","addMarker","id","coordinates","createFeaturesHTML","readonly","createFeatureHTML","join","focusFeature","mapProvider","fitBounds","flattened","flat","points","i","push","slice","p","description","properties","changeAction","deleteAction","focusAction","links","actions","centroidGridReference","coordinateGridReference","generateID","crypto","randomUUID","activeFeature","getActiveFeature","setActiveFeature","resetActiveFeature","prepareGeometry","maxPrecision","formatPrecision","toFixed","forEach","getFeatures","getFeature","find","f","updateFeature","removeFeature","idx","findIndex","splice","getListRenderer","renderValue","renderList","innerHTML","getValueRenderer","stringify","toggleActionButtons","hidden","toggleButtonState","focusDescriptionInput","inputs","querySelectorAll","lastInput","item","focus","select","on","mapReady","onMapReadyFactory","mapEl","document","createElement","setAttribute","listId","after","classList","add","onMapReady","e","addPanel","addButton","variant","iconSvgContent","onClick","enable","newPolygon","newLine","drawReady","onDrawReadyFactory","drawCreated","onDrawCreatedFactory","drawEdited","onDrawEditedFactory","drawCancelled","onDrawCancelledFactory","interactMarkerChange","onInteractMarkerChangedFactory","addEventListener","onListElClickFactory","onListElChangeFactory","onDrawReady","onDrawCreated","onDrawEdited","changedFeature","featureId","onDrawCancelled","onInteractMarkerChange","activeFeatureId","coords","removeMarker","disable","deleteFeature","editFeature","selectFeature","target","HTMLElement","preventDefault","stopPropagation","tagName","dataset","action","HTMLInputElement"],"sources":["../../../src/client/javascripts/geospatial-map.js"],"sourcesContent":["import { bbox } from '@turf/bbox'\n\nimport {\n EVENTS,\n createMap,\n defaultConfig,\n getCentroidGridRef,\n getCoordinateGridRef\n} from '~/src/client/javascripts/map.js'\n\nconst helpPanelConfig = {\n showLabel: true,\n label: 'How to use this map',\n mobile: {\n slot: 'bottom',\n open: true,\n dismissible: true,\n modal: false\n },\n tablet: {\n slot: 'bottom',\n open: true,\n dismissible: true,\n modal: false\n },\n desktop: {\n slot: 'bottom',\n open: true,\n dismissible: true,\n modal: false\n },\n html: '<p class=\"govuk-body-s govuk-!-margin-bottom-2\">You can add points, shapes or lines to the map.</p><ul class=\"govuk-list govuk-list--number govuk-body-s\"><li>Search for a county, place or postcode</li><li>Use the + and - icons to zoom in and out</li><li>Add a point or click \\'Done\\' when you have finished drawing a line or shape</li><li>Give the location a name</li></ul>'\n}\n\nconst lineFeatureProperties = {\n stroke: 'rgba(0, 11, 112, 1)',\n fill: 'rgba(0, 11, 112, 0.2)',\n strokeWidth: 2\n}\n\nconst polygonFeatureProperties = {\n stroke: 'rgba(0,112,60,1)',\n fill: 'rgba(0,112,60,0.2)',\n strokeWidth: 2\n}\n\n/**\n * @type {Record<'Point' | 'LineString' | 'Polygon', string>}\n */\nconst typeDescriptions = {\n Point: 'Point',\n LineString: 'Line',\n Polygon: 'Shape'\n}\n\nconst POINT_SVG =\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\" /><circle cx=\"12\" cy=\"10\" r=\"3\" />'\nconst POLYGON_SVG =\n '<path d=\"M19.5 7v10M4.5 7v10M7 19.5h10M7 4.5h10\"/><path d=\"M22 18v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zm0-15v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 18v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 3v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1z\"/>'\nconst LINE_SVG =\n '<path d=\"M5.706 16.294L16.294 5.706\"/><path d=\"M21 2v3c0 .549-.451 1-1 1h-3c-.549 0-1-.451-1-1V2c0-.549.451-1 1-1h3c.549 0 1 .451 1 1zM6 17v3c0 .549-.451 1-1 1H2c-.549 0-1-.451-1-1v-3c0-.549.451-1 1-1h3c.549 0 1 .451 1 1z\"/>'\n\n/**\n * Extract and parses the GeoJSON from the textarea\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n */\nexport function getGeoJSON(geospatialInput) {\n const value = geospatialInput.value.trim()\n const hasValue = !!value\n\n /** @type {FeatureCollection} */\n const features = hasValue ? JSON.parse(value) : []\n\n /** @type {GeoJSON} */\n const geojson = {\n type: 'FeatureCollection',\n features\n }\n\n return geojson\n}\n\n/**\n * Gets the bounding box covering a feature collection\n * @param {GeoJSON} geojson - the geojson\n */\nexport function getBoundingBox(geojson) {\n return bbox(geojson)\n}\n\n/**\n * Processes a geospatial field to add map capability\n * @param {MapsEnvironmentConfig} config - the geospatial field element\n * @param {Element} geospatial - the geospatial field element\n * @param {number} index - the 0-based index\n */\nexport function processGeospatial(config, geospatial, index) {\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n if (!(geospatial instanceof HTMLDivElement)) {\n return\n }\n\n const geospatialInput = geospatial.querySelector('.govuk-textarea')\n if (!(geospatialInput instanceof HTMLTextAreaElement)) {\n return\n }\n\n const { listEl, mapId } = createContainers(geospatialInput, index)\n const geojson = getGeoJSON(geospatialInput)\n const bounds = geojson.features.length ? getBoundingBox(geojson) : undefined\n const drawPlugin = defra.drawMLPlugin()\n\n const initConfig = {\n ...defaultConfig,\n bounds,\n plugins: [drawPlugin]\n }\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n const featuresManager = getFeaturesManager(geojson)\n const activeFeatureManager = getActiveFeatureManager()\n const uiManager = getUIManager(geojson, map, mapId, listEl, geospatialInput)\n\n /**\n * @type {Context}\n */\n const context = {\n map,\n featuresManager,\n activeFeatureManager,\n uiManager,\n interactPlugin,\n drawPlugin\n }\n\n addEventListeners(context)\n}\n\n/**\n * Adds a feature to the map\n * @param {Feature} feature - the geojson feature\n * @param {any} drawPlugin - the map draw plugin\n * @param {InteractiveMap} map - the interactive map\n */\nexport function addFeatureToMap(feature, drawPlugin, map) {\n switch (feature.geometry.type) {\n case 'Polygon':\n drawPlugin.addFeature({ ...feature, ...polygonFeatureProperties })\n break\n case 'LineString':\n drawPlugin.addFeature({ ...feature, ...lineFeatureProperties })\n break\n case 'Point':\n map.addMarker(feature.id, feature.geometry.coordinates)\n break\n default:\n break\n }\n}\n\n/**\n * Returns HTML summary list for the features\n * @param {FeatureCollection} features - the features\n * @param {string} mapId - the ID of the map\n * @param {boolean} [readonly] - render the list in readonly mode\n */\nexport function createFeaturesHTML(features, mapId, readonly = false) {\n return `<dl class=\"govuk-summary-list\">\n ${features.map((feature, index) => createFeatureHTML(feature, index, mapId, readonly)).join('\\n')}\n </dl>`\n}\n\n/**\n * Focus feature\n * @param {Feature} feature - the feature\n * @param {MapLibreMap} mapProvider - the feature id\n */\nexport function focusFeature(feature, mapProvider) {\n mapProvider.fitBounds(bbox(feature))\n}\n\n/**\n * Returns HTML summary row for an single feature\n * @param {Feature} feature - the geo feature\n * @param {number} index - the feature index\n * @param {string} mapId - the ID of the map\n * @param {boolean} readonly - render the list item in readonly mode\n */\nfunction createFeatureHTML(feature, index, mapId, readonly) {\n const flattened = feature.geometry.coordinates.flat(2)\n\n const points = []\n for (let i = 0; i < flattened.length; i += 2) {\n points.push(flattened.slice(i, i + 2).join(', '))\n }\n const coordinates = points.map((p) => `<li>${p}</li>`).join('')\n\n const description = readonly\n ? `<p class=\"govuk-body govuk-!-margin-bottom-0\">${feature.properties.description}</p>`\n : `<input class=\"govuk-input govuk-!-width-two-thirds\" type=\"text\" id=\"description_${index}\" value=\"${feature.properties.description}\" data-id=\"${feature.id}\">`\n\n // Change action link\n const changeAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#${mapId}\" data-action=\"edit\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Update<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Delete action link\n const deleteAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#\" data-action=\"delete\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Delete<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Focus action link\n const focusAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#${mapId}\" data-action=\"focus\" data-id=\"${feature.id}\">Show<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n const links = readonly ? focusAction() : `${changeAction()}${deleteAction()}`\n\n const actions = `<ul class=\"govuk-summary-list__actions-list\">${links}</ul>`\n\n return `<div class=\"govuk-summary-list__row govuk-summary-list__row--no-border\">\n <dt class=\"govuk-summary-list__key\">\n <div class=\"govuk-form-group\">\n <label class=\"govuk-label govuk-label--s\" ${readonly ? '' : `for=\"description_${index}\"`}>Location ${index + 1} description</label>\n ${description}\n </div>\n </dt>\n <dd class=\"govuk-summary-list__actions\">\n ${actions}\n </dd>\n</div>\n<div class=\"govuk-summary-list__row\">\n <details class=\"govuk-details govuk-!-margin-bottom-2\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">Coordinates</span>\n </summary>\n <div class=\"govuk-details__text\">\n <dl class=\"govuk-summary-list\">\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Type</dt>\n <dd class=\"govuk-summary-list__value\">${typeDescriptions[feature.geometry.type]}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Center grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.centroidGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">First point grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.coordinateGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Detailed coordinates</dt>\n <dd class=\"govuk-summary-list__value\">\n <ol class=\"govuk-list govuk-list--number\">${coordinates}</ol>\n </dd>\n </div>\n </dl>\n </div>\n </details>\n</div>`\n}\n\n/**\n * Generate a random id\n */\nfunction generateID() {\n return window.crypto.randomUUID()\n}\n\n/**\n * Factory closure to track the active feature id\n * @returns {ActiveFeatureManager}\n */\nfunction getActiveFeatureManager() {\n /** @type {string | undefined} */\n let activeFeature\n\n /**\n * Returns the active feature id\n * @type {GetActiveFeature}\n */\n function getActiveFeature() {\n return activeFeature\n }\n\n /**\n * Sets the active feature id\n * @type {SetActiveFeature}\n */\n function setActiveFeature(id) {\n activeFeature = id\n }\n\n /**\n * Resets the active feature id\n * @type {ResetActiveFeature}\n */\n function resetActiveFeature() {\n activeFeature = undefined\n }\n\n return {\n getActiveFeature,\n setActiveFeature,\n resetActiveFeature\n }\n}\n\n/**\n * Reduce coordinate precision to 7 dps\n * @param {Feature} feature\n */\nfunction prepareGeometry(feature) {\n const { geometry } = feature\n const maxPrecision = 7\n\n /**\n * @param {Coordinates} coordinates\n */\n function formatPrecision(coordinates) {\n coordinates[0] = +coordinates[0].toFixed(maxPrecision)\n coordinates[1] = +coordinates[1].toFixed(maxPrecision)\n }\n\n if (geometry.type === 'Point') {\n formatPrecision(geometry.coordinates)\n } else if (geometry.type === 'LineString') {\n geometry.coordinates.forEach(formatPrecision)\n } else {\n geometry.coordinates.flat().forEach(formatPrecision)\n }\n}\n\n/**\n * Factory closure to return a features manager\n * @param {GeoJSON} geojson\n * @returns {FeaturesManager}\n */\nfunction getFeaturesManager(geojson) {\n /**\n * Get a feature from the geojson by id\n * @type {GetFeatures}\n */\n function getFeatures() {\n return geojson.features\n }\n\n /**\n * Get a feature from the geojson by id\n * @type {GetFeature}\n */\n function getFeature(id) {\n return geojson.features.find((f) => f.id === id)\n }\n\n /**\n * Add a feature to the geojson\n * @type {AddFeature}\n */\n function addFeature(feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n prepareGeometry(feature)\n\n geojson.features.push(feature)\n }\n\n /**\n * Updates a feature in the geojson\n * @type {UpdateFeature}\n */\n function updateFeature(id, geometry) {\n const feature = getFeature(id)\n\n // Ensure the feature exists in the geojson\n if (feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n feature.geometry = geometry\n prepareGeometry(feature)\n }\n\n return feature\n }\n\n /**\n * Removes a feature from the geojson\n * @type {RemoveFeature}\n */\n function removeFeature(id) {\n const idx = geojson.features.findIndex((f) => f.id === id)\n\n return idx > -1 ? geojson.features.splice(idx, 1) : undefined\n }\n\n return {\n getFeatures,\n getFeature,\n addFeature,\n updateFeature,\n removeFeature\n }\n}\n\n/**\n * Factory to render features into the list and hidden textarea\n * @param {GeoJSON} geojson - the geojson of features\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {Function} renderValue - function that renders the features JSON into the hidden textarea\n * @returns {RenderList}\n */\nfunction getListRenderer(geojson, mapId, listEl, renderValue) {\n return function renderList() {\n const html = createFeaturesHTML(geojson.features, mapId)\n\n listEl.innerHTML = html\n\n renderValue()\n }\n}\n\n/**\n * Factory to render features JSON into the hidden textarea\n * @param {GeoJSON} geojson - the features\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n * @returns {RenderValue}\n */\nfunction getValueRenderer(geojson, geospatialInput) {\n return function renderValue() {\n geospatialInput.value = JSON.stringify(geojson.features, null, 2)\n }\n}\n\n/**\n * Factory closure to manage the UI\n * @param {GeoJSON} geojson - the features\n * @param {InteractiveMap} map - the map\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n */\nfunction getUIManager(geojson, map, mapId, listEl, geospatialInput) {\n /**\n * Toggle the hidden state of the action buttons\n * @type {ToggleActionButtons}\n */\n function toggleActionButtons(hidden) {\n map.toggleButtonState('btnAddPoint', 'hidden', hidden)\n map.toggleButtonState('btnAddPolygon', 'hidden', hidden)\n map.toggleButtonState('btnAddLine', 'hidden', hidden)\n }\n\n /**\n * Set focus to the last description input\n * @type {FocusDescriptionInput}\n */\n function focusDescriptionInput() {\n const inputs = listEl.querySelectorAll('input')\n if (inputs.length) {\n const lastInput = /** @type {HTMLInputElement} */ inputs.item(\n inputs.length - 1\n )\n lastInput.focus()\n lastInput.select()\n }\n }\n\n const renderValue = getValueRenderer(geojson, geospatialInput)\n const renderList = getListRenderer(geojson, mapId, listEl, renderValue)\n\n /** @type {UIManager} */\n return {\n renderList,\n renderValue,\n listEl,\n toggleActionButtons,\n focusDescriptionInput\n }\n}\n\n/**\n * Setup the UI event listeners\n * @param {Context} context - the context\n */\nfunction addEventListeners(context) {\n const { map } = context\n\n map.on(EVENTS.mapReady, onMapReadyFactory(context))\n}\n\n/**\n * Create the map and list containers and adds them to the DOM\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n * @param {number} index - the 0 based index\n */\nfunction createContainers(geospatialInput, index) {\n const mapEl = document.createElement('div')\n const mapId = `geospatialmap_${index}`\n\n mapEl.setAttribute('id', mapId)\n mapEl.setAttribute('class', 'map-container')\n\n const listEl = document.createElement('div')\n const listId = `${mapId}_list`\n listEl.setAttribute('id', listId)\n\n geospatialInput.after(mapEl)\n mapEl.after(listEl)\n geospatialInput.classList.add('js-hidden')\n\n return { mapEl, listEl, mapId }\n}\n\n/**\n * Callback factory function which fires when the map is ready\n * @param {Context} context - the UI context\n */\nfunction onMapReadyFactory(context) {\n const { map, activeFeatureManager, uiManager, interactPlugin, drawPlugin } =\n context\n const { toggleActionButtons } = uiManager\n const { resetActiveFeature } = activeFeatureManager\n\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n return function onMapReady(e) {\n // Add info panel\n map.addPanel('info', helpPanelConfig)\n\n map.addButton('btnAddPoint', {\n variant: 'tertiary',\n label: 'Add point',\n iconSvgContent: POINT_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n interactPlugin.enable()\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n\n map.addButton('btnAddPolygon', {\n variant: 'tertiary',\n label: 'Add shape',\n iconSvgContent: POLYGON_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n drawPlugin.newPolygon(generateID(), polygonFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n\n map.addButton('btnAddLine', {\n variant: 'tertiary',\n label: 'Add line',\n iconSvgContent: LINE_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n drawPlugin.newLine(generateID(), lineFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n\n // Set the map provider on the context\n context.mapProvider = e.map\n\n map.on(EVENTS.drawReady, onDrawReadyFactory(context))\n map.on(EVENTS.drawCreated, onDrawCreatedFactory(context))\n map.on(EVENTS.drawEdited, onDrawEditedFactory(context))\n map.on(EVENTS.drawCancelled, onDrawCancelledFactory(context))\n map.on(EVENTS.interactMarkerChange, onInteractMarkerChangedFactory(context))\n\n const { listEl } = uiManager\n listEl.addEventListener('click', onListElClickFactory(context), false)\n listEl.addEventListener('change', onListElChangeFactory(context), false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin is ready\n * @param {Context} context - the UI context\n */\nfunction onDrawReadyFactory(context) {\n const { featuresManager, uiManager, drawPlugin, map } = context\n const { renderList } = uiManager\n const { getFeatures } = featuresManager\n\n /**\n * Callback when the draw plugin is ready\n */\n return function onDrawReady() {\n getFeatures().forEach((feature) =>\n addFeatureToMap(feature, drawPlugin, map)\n )\n\n // Update the features\n renderList()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin creates a new feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCreatedFactory(context) {\n const { featuresManager, uiManager } = context\n const { addFeature } = featuresManager\n const { renderList, toggleActionButtons, focusDescriptionInput } = uiManager\n\n /**\n * Callback when a draw feature has been created\n * @param {Feature} e\n */\n return function onDrawCreated(e) {\n // New feature\n addFeature({\n ...e,\n properties: {\n description: ''\n }\n })\n\n // Update the features\n renderList()\n toggleActionButtons(false)\n focusDescriptionInput()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin edits a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawEditedFactory(context) {\n const { featuresManager, activeFeatureManager, uiManager } = context\n const { updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Callback when a draw feature has been edited\n * @param {{ id: string, geometry: Geometry }} e\n */\n return function onDrawEdited(e) {\n const changedFeature = e\n const featureId = changedFeature.id\n\n if (getActiveFeature() === featureId) {\n updateFeature(featureId, changedFeature.geometry)\n\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin cancels the editing of a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCancelledFactory(context) {\n const { uiManager, activeFeatureManager } = context\n const { toggleActionButtons } = uiManager\n const { resetActiveFeature } = activeFeatureManager\n\n /**\n * Callback when a draw feature has been cancelled\n */\n return function onDrawCancelled() {\n toggleActionButtons(false)\n resetActiveFeature()\n }\n}\n\n/**\n * Callback factory function that fires when an interact marker has been changed\n * @param {Context} context - the UI context\n */\nfunction onInteractMarkerChangedFactory(context) {\n const {\n featuresManager,\n activeFeatureManager,\n map,\n interactPlugin,\n uiManager\n } = context\n const { addFeature, updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, focusDescriptionInput, toggleActionButtons } = uiManager\n\n /**\n * Callback when an interact marker has been changed\n * @param {{ coords: Coordinates }} e\n */\n return function onInteractMarkerChange(e) {\n const activeFeatureId = getActiveFeature()\n\n if (activeFeatureId) {\n // Editing an existing point\n const feature = updateFeature(activeFeatureId, {\n type: 'Point',\n coordinates: e.coords\n })\n\n map.addMarker(activeFeatureId, e.coords)\n\n if (feature) {\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n } else {\n // Adding a new point\n const id = generateID()\n addFeature({\n type: 'Feature',\n properties: {\n description: ''\n },\n geometry: {\n type: 'Point',\n coordinates: e.coords\n },\n id\n })\n\n map.addMarker(id, e.coords)\n\n // Update the features\n renderList()\n\n focusDescriptionInput()\n }\n map.removeMarker('location')\n\n interactPlugin.disable()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function that fires a 'click' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElClickFactory(context) {\n const {\n map,\n mapProvider,\n featuresManager,\n activeFeatureManager,\n interactPlugin,\n uiManager,\n drawPlugin\n } = context\n const { getFeature, removeFeature } = featuresManager\n const { getActiveFeature, setActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Delete a feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function deleteFeature(id, type) {\n if (type === 'Point') {\n map.removeMarker(id)\n removeFeature(id)\n } else {\n drawPlugin.deleteFeature(id)\n removeFeature(id)\n }\n\n renderList()\n }\n\n /**\n * Start editing feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function editFeature(id, type) {\n setActiveFeature(id)\n\n // \"Change\" feature link was clicked\n if (type === 'Point') {\n interactPlugin.selectFeature({ featureId: id })\n interactPlugin.enable()\n } else {\n drawPlugin.editFeature(id)\n }\n\n const feature = getFeature(id)\n if (feature && mapProvider) {\n focusFeature(feature, mapProvider)\n }\n\n toggleActionButtons(true)\n }\n\n /**\n * List container delegated 'click' events handler\n * @param {MouseEvent} e\n */\n return function (e) {\n const target = e.target\n\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n if (getActiveFeature()) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (\n target.tagName === 'A' &&\n target.dataset.action &&\n target.dataset.id &&\n target.dataset.type\n ) {\n const { action, id, type } = target.dataset\n\n if (action === 'edit') {\n // \"Update\" feature link was clicked\n editFeature(id, type)\n } else {\n e.preventDefault()\n e.stopPropagation()\n\n if (action === 'delete') {\n // \"Remove\" feature link was clicked\n deleteFeature(id, type)\n }\n }\n }\n }\n}\n\n/**\n * Callback factory function that fires a 'change' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElChangeFactory(context) {\n const { featuresManager, uiManager } = context\n const { getFeature } = featuresManager\n const { renderValue } = uiManager\n\n /**\n * List container delegated 'change' events handler\n * Used to update the description of features\n * @param {Event} e\n */\n return function (e) {\n e.preventDefault()\n e.stopPropagation()\n\n const target = e.target\n if (!(target instanceof HTMLInputElement) || !target.dataset.id) {\n return\n }\n\n const { id } = target.dataset\n const feature = getFeature(id)\n\n if (feature) {\n feature.properties.description = target.value.trim()\n renderValue()\n }\n }\n}\n\n/**\n * @import { MapsEnvironmentConfig, InteractiveMap } from '~/src/client/javascripts/map.js'\n */\n\n/**\n * @import { Geometry, FeatureCollection, Feature, Coordinates } from '~/src/server/plugins/engine/types.js'\n */\n\n/**\n * @typedef {object} GeoJSON\n * @property {'FeatureCollection'} type - the GeoJSON type string\n * @property {FeatureCollection} features - the features\n */\n\n/**\n * Gets all the features\n * @callback GetFeatures\n * @returns {FeatureCollection}\n */\n\n/**\n * Gets a feature from the geojson by id\n * @callback GetFeature\n * @param {string} id - the feature id\n * @returns {Feature | undefined}\n */\n\n/**\n * Add a feature to the geojson\n * @callback AddFeature\n * @param {Feature} feature - the feature to add\n */\n\n/**\n * Update a feature in the geojson\n * @callback UpdateFeature\n * @param {string} id - the feature id\n * @param {Geometry} geometry - the feature geometry\n * @returns {Feature | undefined}\n */\n\n/**\n * Removes a feature from the geojson\n * @callback RemoveFeature\n * @param {string} id - the feature id\n */\n\n/**\n * Gets the active feature id\n * @callback GetActiveFeature\n * @returns {string | undefined}\n */\n\n/**\n * Set the active feature id\n * @callback SetActiveFeature\n * @param {string} id - the feature id\n * @returns {void}\n */\n\n/**\n * Resets the active feature id\n * @callback ResetActiveFeature\n * @returns {void}\n */\n\n/**\n * Renders the features into the list\n * @callback RenderList\n * @returns {void}\n */\n\n/**\n * Renders the features JSON into the hidden textarea\n * @callback RenderValue\n * @returns {void}\n */\n\n/**\n * Toggles the action button hidden state\n * @callback ToggleActionButtons\n * @param {boolean} hidden - whether to hide the action buttons\n * @returns {void}\n */\n\n/**\n * Set focus to the last description input\n * @callback FocusDescriptionInput\n * @returns {void}\n */\n\n/**\n * @typedef {object} FeaturesManager\n * @property {GetFeatures} getFeatures - function that gets all the features\n * @property {GetFeature} getFeature - function that gets a feature from the geojson\n * @property {AddFeature} addFeature - function that adds feature to the geojson\n * @property {UpdateFeature} updateFeature - function that updates a feature in the geojson\n * @property {RemoveFeature} removeFeature - function that removes a feature from the geojson\n */\n\n/**\n * @typedef {object} ActiveFeatureManager\n * @property {GetActiveFeature} getActiveFeature - function that returns the current active feature id\n * @property {SetActiveFeature} setActiveFeature - function that sets the current active feature id\n * @property {ResetActiveFeature} resetActiveFeature - function that resets the current active feature id\n */\n\n/**\n * @typedef {object} UIManager\n * @property {RenderValue} renderValue - function that renders the features JSON into the hidden textarea\n * @property {RenderList} renderList - function that renders the features into the list\n * @property {HTMLDivElement} listEl - the summary list of features\n * @property {ToggleActionButtons} toggleActionButtons - function that toggles the action buttons\n * @property {FocusDescriptionInput} focusDescriptionInput - function that sets focus to a description input element\n */\n\n/**\n * @typedef {object} Context\n * @property {InteractiveMap} map - the interactive map\n * @property {MapLibreMap} [mapProvider] - the interactive map provider\n * @property {FeaturesManager} featuresManager - the features manager\n * @property {ActiveFeatureManager} activeFeatureManager - the active feature manager\n * @property {UIManager} uiManager - the UI manager\n * @property {any} interactPlugin - the map interact plugin\n * @property {any} drawPlugin - the map draw plugin\n */\n\n/**\n * @import { MapLibreMap } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AAEjC,SACEC,MAAM,EACNC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,oBAAoB;AAGtB,MAAMC,eAAe,GAAG;EACtBC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,qBAAqB;EAC5BC,MAAM,EAAE;IACNC,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,IAAI;IACVC,WAAW,EAAE,IAAI;IACj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AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"geospatial-map.js","names":["bbox","EVENTS","createMap","defaultConfig","getCentroidGridRef","getCoordinateGridRef","helpPanelConfig","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","html","lineFeatureProperties","stroke","fill","strokeWidth","polygonFeatureProperties","typeDescriptions","Point","LineString","Polygon","POINT_SVG","POLYGON_SVG","LINE_SVG","getGeoJSON","geospatialInput","value","trim","hasValue","features","JSON","parse","geojson","type","getBoundingBox","processGeospatial","config","geospatial","index","defra","window","HTMLDivElement","querySelector","HTMLTextAreaElement","listEl","mapId","createContainers","bounds","length","undefined","drawPlugin","drawMLPlugin","initConfig","plugins","map","interactPlugin","featuresManager","getFeaturesManager","activeFeatureManager","getActiveFeatureManager","uiManager","getUIManager","context","addEventListeners","addFeatureToMap","feature","geometry","addFeature","addMarker","id","coordinates","createFeaturesHTML","readonly","createFeatureHTML","join","focusFeature","mapProvider","fitBounds","flattened","flat","points","i","push","slice","p","description","properties","changeAction","deleteAction","focusAction","links","actions","centroidGridReference","coordinateGridReference","generateID","crypto","randomUUID","activeFeature","getActiveFeature","setActiveFeature","resetActiveFeature","prepareGeometry","maxPrecision","formatPrecision","toFixed","forEach","getFeatures","getFeature","find","f","updateFeature","removeFeature","idx","findIndex","splice","getListRenderer","renderValue","renderList","innerHTML","getValueRenderer","stringify","toggleActionButtons","hidden","toggleButtonState","focusDescriptionInput","inputs","querySelectorAll","lastInput","item","focus","select","on","mapReady","onMapReadyFactory","mapEl","document","createElement","setAttribute","listId","after","classList","add","onMapReady","e","addPanel","addButton","variant","iconSvgContent","onClick","enable","newPolygon","newLine","drawReady","onDrawReadyFactory","drawCreated","onDrawCreatedFactory","drawEdited","onDrawEditedFactory","drawCancelled","onDrawCancelledFactory","interactMarkerChange","onInteractMarkerChangedFactory","addEventListener","onListElClickFactory","onListElChangeFactory","onDrawReady","onDrawCreated","onDrawEdited","changedFeature","featureId","onDrawCancelled","onInteractMarkerChange","activeFeatureId","coords","removeMarker","disable","deleteFeature","editFeature","selectFeature","target","HTMLElement","preventDefault","stopPropagation","tagName","dataset","action","HTMLInputElement"],"sources":["../../../src/client/javascripts/geospatial-map.js"],"sourcesContent":["import { bbox } from '@turf/bbox'\n\nimport {\n EVENTS,\n createMap,\n defaultConfig,\n getCentroidGridRef,\n getCoordinateGridRef\n} from '~/src/client/javascripts/map.js'\n\nconst helpPanelConfig = {\n showLabel: true,\n label: 'How to use this map',\n mobile: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n tablet: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n desktop: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n html: '<p class=\"govuk-body-s govuk-!-margin-bottom-2\">You can add points, shapes or lines to the map.</p><ul class=\"govuk-list govuk-list--number govuk-body-s\"><li>Search for a county, place or postcode</li><li>Use the + and - icons to zoom in and out</li><li>Add a point or click \\'Done\\' when you have finished drawing a line or shape</li><li>Give the location a name</li></ul>'\n}\n\nconst lineFeatureProperties = {\n stroke: 'rgba(0, 11, 112, 1)',\n fill: 'rgba(0, 11, 112, 0.2)',\n strokeWidth: 2\n}\n\nconst polygonFeatureProperties = {\n stroke: 'rgba(0,112,60,1)',\n fill: 'rgba(0,112,60,0.2)',\n strokeWidth: 2\n}\n\n/**\n * @type {Record<'Point' | 'LineString' | 'Polygon', string>}\n */\nconst typeDescriptions = {\n Point: 'Point',\n LineString: 'Line',\n Polygon: 'Shape'\n}\n\nconst POINT_SVG =\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\" /><circle cx=\"12\" cy=\"10\" r=\"3\" />'\nconst POLYGON_SVG =\n '<path d=\"M19.5 7v10M4.5 7v10M7 19.5h10M7 4.5h10\"/><path d=\"M22 18v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zm0-15v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 18v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 3v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1z\"/>'\nconst LINE_SVG =\n '<path d=\"M5.706 16.294L16.294 5.706\"/><path d=\"M21 2v3c0 .549-.451 1-1 1h-3c-.549 0-1-.451-1-1V2c0-.549.451-1 1-1h3c.549 0 1 .451 1 1zM6 17v3c0 .549-.451 1-1 1H2c-.549 0-1-.451-1-1v-3c0-.549.451-1 1-1h3c.549 0 1 .451 1 1z\"/>'\n\n/**\n * Extract and parses the GeoJSON from the textarea\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n */\nexport function getGeoJSON(geospatialInput) {\n const value = geospatialInput.value.trim()\n const hasValue = !!value\n\n /** @type {FeatureCollection} */\n const features = hasValue ? JSON.parse(value) : []\n\n /** @type {GeoJSON} */\n const geojson = {\n type: 'FeatureCollection',\n features\n }\n\n return geojson\n}\n\n/**\n * Gets the bounding box covering a feature collection\n * @param {GeoJSON} geojson - the geojson\n */\nexport function getBoundingBox(geojson) {\n return bbox(geojson)\n}\n\n/**\n * Processes a geospatial field to add map capability\n * @param {MapsEnvironmentConfig} config - the geospatial field element\n * @param {Element} geospatial - the geospatial field element\n * @param {number} index - the 0-based index\n */\nexport function processGeospatial(config, geospatial, index) {\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n if (!(geospatial instanceof HTMLDivElement)) {\n return\n }\n\n const geospatialInput = geospatial.querySelector('.govuk-textarea')\n if (!(geospatialInput instanceof HTMLTextAreaElement)) {\n return\n }\n\n const { listEl, mapId } = createContainers(geospatialInput, index)\n const geojson = getGeoJSON(geospatialInput)\n const bounds = geojson.features.length ? getBoundingBox(geojson) : undefined\n const drawPlugin = defra.drawMLPlugin()\n\n const initConfig = {\n ...defaultConfig,\n bounds,\n plugins: [drawPlugin]\n }\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n const featuresManager = getFeaturesManager(geojson)\n const activeFeatureManager = getActiveFeatureManager()\n const uiManager = getUIManager(geojson, map, mapId, listEl, geospatialInput)\n\n /**\n * @type {Context}\n */\n const context = {\n map,\n featuresManager,\n activeFeatureManager,\n uiManager,\n interactPlugin,\n drawPlugin\n }\n\n addEventListeners(context)\n}\n\n/**\n * Adds a feature to the map\n * @param {Feature} feature - the geojson feature\n * @param {any} drawPlugin - the map draw plugin\n * @param {InteractiveMap} map - the interactive map\n */\nexport function addFeatureToMap(feature, drawPlugin, map) {\n switch (feature.geometry.type) {\n case 'Polygon':\n drawPlugin.addFeature({ ...feature, ...polygonFeatureProperties })\n break\n case 'LineString':\n drawPlugin.addFeature({ ...feature, ...lineFeatureProperties })\n break\n case 'Point':\n map.addMarker(feature.id, feature.geometry.coordinates)\n break\n default:\n break\n }\n}\n\n/**\n * Returns HTML summary list for the features\n * @param {FeatureCollection} features - the features\n * @param {string} mapId - the ID of the map\n * @param {boolean} [readonly] - render the list in readonly mode\n */\nexport function createFeaturesHTML(features, mapId, readonly = false) {\n return `<dl class=\"govuk-summary-list\">\n ${features.map((feature, index) => createFeatureHTML(feature, index, mapId, readonly)).join('\\n')}\n </dl>`\n}\n\n/**\n * Focus feature\n * @param {Feature} feature - the feature\n * @param {MapLibreMap} mapProvider - the feature id\n */\nexport function focusFeature(feature, mapProvider) {\n mapProvider.fitBounds(bbox(feature))\n}\n\n/**\n * Returns HTML summary row for an single feature\n * @param {Feature} feature - the geo feature\n * @param {number} index - the feature index\n * @param {string} mapId - the ID of the map\n * @param {boolean} readonly - render the list item in readonly mode\n */\nfunction createFeatureHTML(feature, index, mapId, readonly) {\n const flattened = feature.geometry.coordinates.flat(2)\n\n const points = []\n for (let i = 0; i < flattened.length; i += 2) {\n points.push(flattened.slice(i, i + 2).join(', '))\n }\n const coordinates = points.map((p) => `<li>${p}</li>`).join('')\n\n const description = readonly\n ? `<p class=\"govuk-body govuk-!-margin-bottom-0\">${feature.properties.description}</p>`\n : `<input class=\"govuk-input govuk-!-width-two-thirds\" type=\"text\" id=\"description_${index}\" value=\"${feature.properties.description}\" data-id=\"${feature.id}\">`\n\n // Change action link\n const changeAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#${mapId}\" data-action=\"edit\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Update<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Delete action link\n const deleteAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#\" data-action=\"delete\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Delete<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Focus action link\n const focusAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#${mapId}\" data-action=\"focus\" data-id=\"${feature.id}\">Show<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n const links = readonly ? focusAction() : `${changeAction()}${deleteAction()}`\n\n const actions = `<ul class=\"govuk-summary-list__actions-list\">${links}</ul>`\n\n return `<div class=\"govuk-summary-list__row govuk-summary-list__row--no-border\">\n <dt class=\"govuk-summary-list__key\">\n <div class=\"govuk-form-group\">\n <label class=\"govuk-label govuk-label--s\" ${readonly ? '' : `for=\"description_${index}\"`}>Location ${index + 1} description</label>\n ${description}\n </div>\n </dt>\n <dd class=\"govuk-summary-list__actions\">\n ${actions}\n </dd>\n</div>\n<div class=\"govuk-summary-list__row\">\n <details class=\"govuk-details govuk-!-margin-bottom-2\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">Coordinates</span>\n </summary>\n <div class=\"govuk-details__text\">\n <dl class=\"govuk-summary-list\">\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Type</dt>\n <dd class=\"govuk-summary-list__value\">${typeDescriptions[feature.geometry.type]}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Centre grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.centroidGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">First point grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.coordinateGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Detailed coordinates</dt>\n <dd class=\"govuk-summary-list__value\">\n <ol class=\"govuk-list govuk-list--number\">${coordinates}</ol>\n </dd>\n </div>\n </dl>\n </div>\n </details>\n</div>`\n}\n\n/**\n * Generate a random id\n */\nfunction generateID() {\n return window.crypto.randomUUID()\n}\n\n/**\n * Factory closure to track the active feature id\n * @returns {ActiveFeatureManager}\n */\nfunction getActiveFeatureManager() {\n /** @type {string | undefined} */\n let activeFeature\n\n /**\n * Returns the active feature id\n * @type {GetActiveFeature}\n */\n function getActiveFeature() {\n return activeFeature\n }\n\n /**\n * Sets the active feature id\n * @type {SetActiveFeature}\n */\n function setActiveFeature(id) {\n activeFeature = id\n }\n\n /**\n * Resets the active feature id\n * @type {ResetActiveFeature}\n */\n function resetActiveFeature() {\n activeFeature = undefined\n }\n\n return {\n getActiveFeature,\n setActiveFeature,\n resetActiveFeature\n }\n}\n\n/**\n * Reduce coordinate precision to 7 dps\n * @param {Feature} feature\n */\nfunction prepareGeometry(feature) {\n const { geometry } = feature\n const maxPrecision = 7\n\n /**\n * @param {Coordinates} coordinates\n */\n function formatPrecision(coordinates) {\n coordinates[0] = +coordinates[0].toFixed(maxPrecision)\n coordinates[1] = +coordinates[1].toFixed(maxPrecision)\n }\n\n if (geometry.type === 'Point') {\n formatPrecision(geometry.coordinates)\n } else if (geometry.type === 'LineString') {\n geometry.coordinates.forEach(formatPrecision)\n } else {\n geometry.coordinates.flat().forEach(formatPrecision)\n }\n}\n\n/**\n * Factory closure to return a features manager\n * @param {GeoJSON} geojson\n * @returns {FeaturesManager}\n */\nfunction getFeaturesManager(geojson) {\n /**\n * Get a feature from the geojson by id\n * @type {GetFeatures}\n */\n function getFeatures() {\n return geojson.features\n }\n\n /**\n * Get a feature from the geojson by id\n * @type {GetFeature}\n */\n function getFeature(id) {\n return geojson.features.find((f) => f.id === id)\n }\n\n /**\n * Add a feature to the geojson\n * @type {AddFeature}\n */\n function addFeature(feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n prepareGeometry(feature)\n\n geojson.features.push(feature)\n }\n\n /**\n * Updates a feature in the geojson\n * @type {UpdateFeature}\n */\n function updateFeature(id, geometry) {\n const feature = getFeature(id)\n\n // Ensure the feature exists in the geojson\n if (feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n feature.geometry = geometry\n prepareGeometry(feature)\n }\n\n return feature\n }\n\n /**\n * Removes a feature from the geojson\n * @type {RemoveFeature}\n */\n function removeFeature(id) {\n const idx = geojson.features.findIndex((f) => f.id === id)\n\n return idx > -1 ? geojson.features.splice(idx, 1) : undefined\n }\n\n return {\n getFeatures,\n getFeature,\n addFeature,\n updateFeature,\n removeFeature\n }\n}\n\n/**\n * Factory to render features into the list and hidden textarea\n * @param {GeoJSON} geojson - the geojson of features\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {Function} renderValue - function that renders the features JSON into the hidden textarea\n * @returns {RenderList}\n */\nfunction getListRenderer(geojson, mapId, listEl, renderValue) {\n return function renderList() {\n const html = createFeaturesHTML(geojson.features, mapId)\n\n listEl.innerHTML = html\n\n renderValue()\n }\n}\n\n/**\n * Factory to render features JSON into the hidden textarea\n * @param {GeoJSON} geojson - the features\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n * @returns {RenderValue}\n */\nfunction getValueRenderer(geojson, geospatialInput) {\n return function renderValue() {\n geospatialInput.value = JSON.stringify(geojson.features, null, 2)\n }\n}\n\n/**\n * Factory closure to manage the UI\n * @param {GeoJSON} geojson - the features\n * @param {InteractiveMap} map - the map\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n */\nfunction getUIManager(geojson, map, mapId, listEl, geospatialInput) {\n /**\n * Toggle the hidden state of the action buttons\n * @type {ToggleActionButtons}\n */\n function toggleActionButtons(hidden) {\n map.toggleButtonState('btnAddPoint', 'hidden', hidden)\n map.toggleButtonState('btnAddPolygon', 'hidden', hidden)\n map.toggleButtonState('btnAddLine', 'hidden', hidden)\n }\n\n /**\n * Set focus to the last description input\n * @type {FocusDescriptionInput}\n */\n function focusDescriptionInput() {\n const inputs = listEl.querySelectorAll('input')\n if (inputs.length) {\n const lastInput = /** @type {HTMLInputElement} */ inputs.item(\n inputs.length - 1\n )\n lastInput.focus()\n lastInput.select()\n }\n }\n\n const renderValue = getValueRenderer(geojson, geospatialInput)\n const renderList = getListRenderer(geojson, mapId, listEl, renderValue)\n\n /** @type {UIManager} */\n return {\n renderList,\n renderValue,\n listEl,\n toggleActionButtons,\n focusDescriptionInput\n }\n}\n\n/**\n * Setup the UI event listeners\n * @param {Context} context - the context\n */\nfunction addEventListeners(context) {\n const { map } = context\n\n map.on(EVENTS.mapReady, onMapReadyFactory(context))\n}\n\n/**\n * Create the map and list containers and adds them to the DOM\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n * @param {number} index - the 0 based index\n */\nfunction createContainers(geospatialInput, index) {\n const mapEl = document.createElement('div')\n const mapId = `geospatialmap_${index}`\n\n mapEl.setAttribute('id', mapId)\n mapEl.setAttribute('class', 'map-container')\n\n const listEl = document.createElement('div')\n const listId = `${mapId}_list`\n listEl.setAttribute('id', listId)\n\n geospatialInput.after(mapEl)\n mapEl.after(listEl)\n geospatialInput.classList.add('js-hidden')\n\n return { mapEl, listEl, mapId }\n}\n\n/**\n * Callback factory function which fires when the map is ready\n * @param {Context} context - the UI context\n */\nfunction onMapReadyFactory(context) {\n const { map, activeFeatureManager, uiManager, interactPlugin, drawPlugin } =\n context\n const { toggleActionButtons } = uiManager\n const { resetActiveFeature } = activeFeatureManager\n\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n return function onMapReady(e) {\n // Add info panel\n map.addPanel('info', helpPanelConfig)\n\n map.addButton('btnAddPoint', {\n variant: 'tertiary',\n label: 'Add point',\n iconSvgContent: POINT_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n interactPlugin.enable()\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n\n map.addButton('btnAddPolygon', {\n variant: 'tertiary',\n label: 'Add shape',\n iconSvgContent: POLYGON_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n drawPlugin.newPolygon(generateID(), polygonFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n\n map.addButton('btnAddLine', {\n variant: 'tertiary',\n label: 'Add line',\n iconSvgContent: LINE_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n drawPlugin.newLine(generateID(), lineFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n\n // Set the map provider on the context\n context.mapProvider = e.map\n\n map.on(EVENTS.drawReady, onDrawReadyFactory(context))\n map.on(EVENTS.drawCreated, onDrawCreatedFactory(context))\n map.on(EVENTS.drawEdited, onDrawEditedFactory(context))\n map.on(EVENTS.drawCancelled, onDrawCancelledFactory(context))\n map.on(EVENTS.interactMarkerChange, onInteractMarkerChangedFactory(context))\n\n const { listEl } = uiManager\n listEl.addEventListener('click', onListElClickFactory(context), false)\n listEl.addEventListener('change', onListElChangeFactory(context), false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin is ready\n * @param {Context} context - the UI context\n */\nfunction onDrawReadyFactory(context) {\n const { featuresManager, uiManager, drawPlugin, map } = context\n const { renderList } = uiManager\n const { getFeatures } = featuresManager\n\n /**\n * Callback when the draw plugin is ready\n */\n return function onDrawReady() {\n getFeatures().forEach((feature) =>\n addFeatureToMap(feature, drawPlugin, map)\n )\n\n // Update the features\n renderList()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin creates a new feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCreatedFactory(context) {\n const { featuresManager, uiManager } = context\n const { addFeature } = featuresManager\n const { renderList, toggleActionButtons, focusDescriptionInput } = uiManager\n\n /**\n * Callback when a draw feature has been created\n * @param {Feature} e\n */\n return function onDrawCreated(e) {\n // New feature\n addFeature({\n ...e,\n properties: {\n description: ''\n }\n })\n\n // Update the features\n renderList()\n toggleActionButtons(false)\n focusDescriptionInput()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin edits a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawEditedFactory(context) {\n const { featuresManager, activeFeatureManager, uiManager } = context\n const { updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Callback when a draw feature has been edited\n * @param {{ id: string, geometry: Geometry }} e\n */\n return function onDrawEdited(e) {\n const changedFeature = e\n const featureId = changedFeature.id\n\n if (getActiveFeature() === featureId) {\n updateFeature(featureId, changedFeature.geometry)\n\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin cancels the editing of a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCancelledFactory(context) {\n const { uiManager, activeFeatureManager } = context\n const { toggleActionButtons } = uiManager\n const { resetActiveFeature } = activeFeatureManager\n\n /**\n * Callback when a draw feature has been cancelled\n */\n return function onDrawCancelled() {\n toggleActionButtons(false)\n resetActiveFeature()\n }\n}\n\n/**\n * Callback factory function that fires when an interact marker has been changed\n * @param {Context} context - the UI context\n */\nfunction onInteractMarkerChangedFactory(context) {\n const {\n featuresManager,\n activeFeatureManager,\n map,\n interactPlugin,\n uiManager\n } = context\n const { addFeature, updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, focusDescriptionInput, toggleActionButtons } = uiManager\n\n /**\n * Callback when an interact marker has been changed\n * @param {{ coords: Coordinates }} e\n */\n return function onInteractMarkerChange(e) {\n const activeFeatureId = getActiveFeature()\n\n if (activeFeatureId) {\n // Editing an existing point\n const feature = updateFeature(activeFeatureId, {\n type: 'Point',\n coordinates: e.coords\n })\n\n map.addMarker(activeFeatureId, e.coords)\n\n if (feature) {\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n } else {\n // Adding a new point\n const id = generateID()\n addFeature({\n type: 'Feature',\n properties: {\n description: ''\n },\n geometry: {\n type: 'Point',\n coordinates: e.coords\n },\n id\n })\n\n map.addMarker(id, e.coords)\n\n // Update the features\n renderList()\n\n focusDescriptionInput()\n }\n map.removeMarker('location')\n\n interactPlugin.disable()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function that fires a 'click' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElClickFactory(context) {\n const {\n map,\n mapProvider,\n featuresManager,\n activeFeatureManager,\n interactPlugin,\n uiManager,\n drawPlugin\n } = context\n const { getFeature, removeFeature } = featuresManager\n const { getActiveFeature, setActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Delete a feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function deleteFeature(id, type) {\n if (type === 'Point') {\n map.removeMarker(id)\n removeFeature(id)\n } else {\n drawPlugin.deleteFeature(id)\n removeFeature(id)\n }\n\n renderList()\n }\n\n /**\n * Start editing feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function editFeature(id, type) {\n setActiveFeature(id)\n\n // \"Change\" feature link was clicked\n if (type === 'Point') {\n interactPlugin.selectFeature({ featureId: id })\n interactPlugin.enable()\n } else {\n drawPlugin.editFeature(id)\n }\n\n const feature = getFeature(id)\n if (feature && mapProvider) {\n focusFeature(feature, mapProvider)\n }\n\n toggleActionButtons(true)\n }\n\n /**\n * List container delegated 'click' events handler\n * @param {MouseEvent} e\n */\n return function (e) {\n const target = e.target\n\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n if (getActiveFeature()) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (\n target.tagName === 'A' &&\n target.dataset.action &&\n target.dataset.id &&\n target.dataset.type\n ) {\n const { action, id, type } = target.dataset\n\n if (action === 'edit') {\n // \"Update\" feature link was clicked\n editFeature(id, type)\n } else {\n e.preventDefault()\n e.stopPropagation()\n\n if (action === 'delete') {\n // \"Remove\" feature link was clicked\n deleteFeature(id, type)\n }\n }\n }\n }\n}\n\n/**\n * Callback factory function that fires a 'change' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElChangeFactory(context) {\n const { featuresManager, uiManager } = context\n const { getFeature } = featuresManager\n const { renderValue } = uiManager\n\n /**\n * List container delegated 'change' events handler\n * Used to update the description of features\n * @param {Event} e\n */\n return function (e) {\n e.preventDefault()\n e.stopPropagation()\n\n const target = e.target\n if (!(target instanceof HTMLInputElement) || !target.dataset.id) {\n return\n }\n\n const { id } = target.dataset\n const feature = getFeature(id)\n\n if (feature) {\n feature.properties.description = target.value.trim()\n renderValue()\n }\n }\n}\n\n/**\n * @import { MapsEnvironmentConfig, InteractiveMap } from '~/src/client/javascripts/map.js'\n */\n\n/**\n * @import { Geometry, FeatureCollection, Feature, Coordinates } from '~/src/server/plugins/engine/types.js'\n */\n\n/**\n * @typedef {object} GeoJSON\n * @property {'FeatureCollection'} type - the GeoJSON type string\n * @property {FeatureCollection} features - the features\n */\n\n/**\n * Gets all the features\n * @callback GetFeatures\n * @returns {FeatureCollection}\n */\n\n/**\n * Gets a feature from the geojson by id\n * @callback GetFeature\n * @param {string} id - the feature id\n * @returns {Feature | undefined}\n */\n\n/**\n * Add a feature to the geojson\n * @callback AddFeature\n * @param {Feature} feature - the feature to add\n */\n\n/**\n * Update a feature in the geojson\n * @callback UpdateFeature\n * @param {string} id - the feature id\n * @param {Geometry} geometry - the feature geometry\n * @returns {Feature | undefined}\n */\n\n/**\n * Removes a feature from the geojson\n * @callback RemoveFeature\n * @param {string} id - the feature id\n */\n\n/**\n * Gets the active feature id\n * @callback GetActiveFeature\n * @returns {string | undefined}\n */\n\n/**\n * Set the active feature id\n * @callback SetActiveFeature\n * @param {string} id - the feature id\n * @returns {void}\n */\n\n/**\n * Resets the active feature id\n * @callback ResetActiveFeature\n * @returns {void}\n */\n\n/**\n * Renders the features into the list\n * @callback RenderList\n * @returns {void}\n */\n\n/**\n * Renders the features JSON into the hidden textarea\n * @callback RenderValue\n * @returns {void}\n */\n\n/**\n * Toggles the action button hidden state\n * @callback ToggleActionButtons\n * @param {boolean} hidden - whether to hide the action buttons\n * @returns {void}\n */\n\n/**\n * Set focus to the last description input\n * @callback FocusDescriptionInput\n * @returns {void}\n */\n\n/**\n * @typedef {object} FeaturesManager\n * @property {GetFeatures} getFeatures - function that gets all the features\n * @property {GetFeature} getFeature - function that gets a feature from the geojson\n * @property {AddFeature} addFeature - function that adds feature to the geojson\n * @property {UpdateFeature} updateFeature - function that updates a feature in the geojson\n * @property {RemoveFeature} removeFeature - function that removes a feature from the geojson\n */\n\n/**\n * @typedef {object} ActiveFeatureManager\n * @property {GetActiveFeature} getActiveFeature - function that returns the current active feature id\n * @property {SetActiveFeature} setActiveFeature - function that sets the current active feature id\n * @property {ResetActiveFeature} resetActiveFeature - function that resets the current active feature id\n */\n\n/**\n * @typedef {object} UIManager\n * @property {RenderValue} renderValue - function that renders the features JSON into the hidden textarea\n * @property {RenderList} renderList - function that renders the features into the list\n * @property {HTMLDivElement} listEl - the summary list of features\n * @property {ToggleActionButtons} toggleActionButtons - function that toggles the action buttons\n * @property {FocusDescriptionInput} focusDescriptionInput - function that sets focus to a description input element\n */\n\n/**\n * @typedef {object} Context\n * @property {InteractiveMap} map - the interactive map\n * @property {MapLibreMap} [mapProvider] - the interactive map provider\n * @property {FeaturesManager} featuresManager - the features manager\n * @property {ActiveFeatureManager} activeFeatureManager - the active feature manager\n * @property {UIManager} uiManager - the UI manager\n * @property {any} interactPlugin - the map interact plugin\n * @property {any} drawPlugin - the map draw plugin\n */\n\n/**\n * @import { MapLibreMap } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AAEjC,SACEC,MAAM,EACNC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,oBAAoB;AAGtB,MAAMC,eAAe,GAAG;EACtBC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,qBAAqB;EAC5BC,MAAM,EAAE;IACNC,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,IAAI;IACVC,WAAW,EAAE,IAAI;IACjBC,KAAK,EAAE;EACT,CAAC;EACDC,MAAM,EAAE;I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A;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
@@ -411,19 +411,19 @@ export function processLocation(config, location, index) {
411
411
  showLabel: true,
412
412
  label: 'How to use the map',
413
413
  mobile: {
414
- slot: 'bottom',
414
+ slot: 'drawer',
415
415
  open: true,
416
416
  dismissible: true,
417
417
  modal: false
418
418
  },
419
419
  tablet: {
420
- slot: 'bottom',
420
+ slot: 'drawer',
421
421
  open: true,
422
422
  dismissible: true,
423
423
  modal: false
424
424
  },
425
425
  desktop: {
426
- slot: 'bottom',
426
+ slot: 'drawer',
427
427
  open: true,
428
428
  dismissible: true,
429
429
  modal: false
@@ -1 +1 @@
1
- {"version":3,"file":"location-map.js","names":["EVENTS","centerMap","createMap","defaultConfig","eastingNorthingToLatLong","latLongToEastingNorthing","latLongToOsGridRef","osGridRefToLatLong","LOCATION_FIELD_SELECTOR","getInitMapConfig","locationField","locationType","dataset","locationtype","getInitLatLongMapConfig","getInitEastingNorthingMapConfig","getInitOsGridRefMapConfig","Error","validateLatLong","strLat","strLong","lat","trim","Number","long","valid","latMin","latMax","longMin","longMax","latInBounds","longInBounds","value","validateEastingNorthing","strEasting","strNorthing","easting","northing","eastingMin","eastingMax","northingMin","northingMax","validateOsGridRef","osGridRef","pattern","match","exec","getLatLongInputs","inputs","querySelectorAll","length","latInput","longInput","getEastingNorthingInputs","eastingInput","northingInput","getOsGridRefInput","input","querySelector","getInitMapCenterConfig","center","zoom","markers","id","coords","result","undefined","latlong","osGridRefInput","bindLatLongField","map","mapProvider","on","interactMarkerChange","onInteractMarkerChange","e","maxPrecision","toFixed","onUpdateInputs","addEventListener","bindEastingNorthingField","point","bindOsGridRefField","onUpdateInput","processLocation","config","location","index","HTMLDivElement","locationInputs","supportedLocations","includes","mapContainer","document","createElement","mapId","setAttribute","initConfig","after","interactPlugin","mapReady","onMapReady","addPanel","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","html","enable"],"sources":["../../../src/client/javascripts/location-map.js"],"sourcesContent":["import {\n EVENTS,\n centerMap,\n createMap,\n defaultConfig,\n eastingNorthingToLatLong,\n latLongToEastingNorthing,\n latLongToOsGridRef,\n osGridRefToLatLong\n} from '~/src/client/javascripts/map.js'\n\nconst LOCATION_FIELD_SELECTOR = 'input.govuk-input'\n\n/**\n * Gets initial map config for a location field\n * @param {HTMLDivElement} locationField - the location field element\n */\nfunction getInitMapConfig(locationField) {\n const locationType = locationField.dataset.locationtype\n\n switch (locationType) {\n case 'latlongfield':\n return getInitLatLongMapConfig(locationField)\n case 'eastingnorthingfield':\n return getInitEastingNorthingMapConfig(locationField)\n case 'osgridreffield':\n return getInitOsGridRefMapConfig(locationField)\n default:\n throw new Error('Not implemented')\n }\n}\n\n/**\n * Validates lat and long is numeric and within UK bounds\n * @param {string} strLat - the latitude string\n * @param {string} strLong - the longitude string\n * @returns {{ valid: false } | { valid: true, value: { lat: number, long: number } }}\n */\nfunction validateLatLong(strLat, strLong) {\n const lat = strLat.trim() && Number(strLat.trim())\n const long = strLong.trim() && Number(strLong.trim())\n\n if (!lat || !long) {\n return { valid: false }\n }\n\n const latMin = 49.85\n const latMax = 60.859\n const longMin = -13.687\n const longMax = 1.767\n\n const latInBounds = lat >= latMin && lat <= latMax\n const longInBounds = long >= longMin && long <= longMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { lat, long } }\n}\n\n/**\n * Validates easting and northing is numeric and within UK bounds\n * @param {string} strEasting - the easting string\n * @param {string} strNorthing - the northing string\n * @returns {{ valid: false } | { valid: true, value: { easting: number, northing: number } }}\n */\nfunction validateEastingNorthing(strEasting, strNorthing) {\n const easting = strEasting.trim() && Number(strEasting.trim())\n const northing = strNorthing.trim() && Number(strNorthing.trim())\n\n if (!easting || !northing) {\n return { valid: false }\n }\n\n const eastingMin = 0\n const eastingMax = 700000\n const northingMin = 0\n const northingMax = 1300000\n\n const latInBounds = easting >= eastingMin && easting <= eastingMax\n const longInBounds = northing >= northingMin && northing <= northingMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { easting, northing } }\n}\n\n/**\n * Validates OS grid reference is correct\n * @param {string} osGridRef - the OsGridRef\n * @returns {{ valid: false } | { valid: true, value: string }}\n */\nfunction validateOsGridRef(osGridRef) {\n if (!osGridRef) {\n return { valid: false }\n }\n\n const pattern =\n /^((([sS]|[nN])[a-hA-Hj-zJ-Z])|(([tT]|[oO])[abfglmqrvwABFGLMQRVW])|([hH][l-zL-Z])|([jJ][lmqrvwLMQRVW]))\\s?(([0-9]{3})\\s?([0-9]{3})|([0-9]{4})\\s?([0-9]{4})|([0-9]{5})\\s?([0-9]{5}))$/\n\n const match = pattern.exec(osGridRef)\n\n if (match === null) {\n return { valid: false }\n }\n\n return { valid: true, value: match[0] }\n}\n\n/**\n * Gets the inputs for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n */\nfunction getLatLongInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for lat and long')\n }\n\n const latInput = /** @type {HTMLInputElement} */ (inputs[0])\n const longInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { latInput, longInput }\n}\n\n/**\n * Gets the inputs for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n */\nfunction getEastingNorthingInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for easting and northing')\n }\n\n const eastingInput = /** @type {HTMLInputElement} */ (inputs[0])\n const northingInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { eastingInput, northingInput }\n}\n\n/**\n * Gets the input for a OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n */\nfunction getOsGridRefInput(locationField) {\n const input = locationField.querySelector(LOCATION_FIELD_SELECTOR)\n\n if (input === null) {\n throw new Error('Expected 1 input for osgridref')\n }\n\n return /** @type {HTMLInputElement} */ (input)\n}\n\n/**\n * Get the initial map config for a center point\n * @param {MapCenter} center - the point\n */\nfunction getInitMapCenterConfig(center) {\n return {\n zoom: '16',\n center,\n markers: [\n {\n id: 'location',\n coords: center\n }\n ]\n }\n}\n\n/**\n * Gets initial map config for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitLatLongMapConfig(locationField) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitEastingNorthingMapConfig(locationField) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for an OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitOsGridRefMapConfig(locationField) {\n const osGridRefInput = getOsGridRefInput(locationField)\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Bind a latlong field to the map\n * @param {HTMLDivElement} locationField - the latlong location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindLatLongField(locationField, map, mapProvider) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 7\n latInput.value = e.coords[1].toFixed(maxPrecision)\n longInput.value = e.coords[0].toFixed(maxPrecision)\n }\n )\n\n /**\n * Lat & long input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (result.valid) {\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n latInput.addEventListener('change', onUpdateInputs, false)\n longInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an eastingnorthing field to the map\n * @param {HTMLDivElement} locationField - the eastingnorthing location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindEastingNorthingField(locationField, map, mapProvider) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 0\n const point = latLongToEastingNorthing({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n eastingInput.value = point.easting.toFixed(maxPrecision)\n northingInput.value = point.northing.toFixed(maxPrecision)\n }\n )\n\n /**\n * Easting & northing input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (result.valid) {\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n eastingInput.addEventListener('change', onUpdateInputs, false)\n northingInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an OS grid reference field to the map\n * @param {HTMLDivElement} locationField - the osgridref location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindOsGridRefField(locationField, map, mapProvider) {\n const osGridRefInput = getOsGridRefInput(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const point = latLongToOsGridRef({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n osGridRefInput.value = point\n }\n )\n\n /**\n * OS grid reference input change event listener\n * Update the map view location when the input is changed\n */\n function onUpdateInput() {\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (result.valid) {\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n osGridRefInput.addEventListener('change', onUpdateInput, false)\n}\n\n/**\n * Processes a location field to add map capability\n * @param {MapsEnvironmentConfig} config - the location field element\n * @param {Element} location - the location field element\n * @param {number} index - the 0-based index\n */\nexport function processLocation(config, location, index) {\n if (!(location instanceof HTMLDivElement)) {\n return\n }\n\n const locationInputs = location.querySelector('.app-location-field-inputs')\n if (!(locationInputs instanceof HTMLDivElement)) {\n return\n }\n const locationType = location.dataset.locationtype\n\n // Check for support\n const supportedLocations = [\n 'latlongfield',\n 'eastingnorthingfield',\n 'osgridreffield'\n ]\n if (!locationType || !supportedLocations.includes(locationType)) {\n return\n }\n\n const mapContainer = document.createElement('div')\n const mapId = `map_${index}`\n\n mapContainer.setAttribute('id', mapId)\n mapContainer.setAttribute('class', 'map-container')\n\n const initConfig = getInitMapConfig(location) ?? defaultConfig\n\n locationInputs.after(mapContainer)\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n\n map.on(\n EVENTS.mapReady,\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n function onMapReady(e) {\n switch (locationType) {\n case 'latlongfield':\n bindLatLongField(location, map, e.map)\n break\n case 'eastingnorthingfield':\n bindEastingNorthingField(location, map, e.map)\n break\n case 'osgridreffield':\n bindOsGridRefField(location, map, e.map)\n break\n default:\n throw new Error('Not implemented')\n }\n\n // Add info panel\n map.addPanel('info', {\n showLabel: true,\n label: 'How to use the map',\n mobile: {\n slot: 'bottom',\n open: true,\n dismissible: true,\n modal: false\n },\n tablet: {\n slot: 'bottom',\n open: true,\n dismissible: true,\n modal: false\n },\n desktop: {\n slot: 'bottom',\n open: true,\n dismissible: true,\n modal: false\n },\n html: 'If using a map click on a point to update the location.<br><br>If using a keyboard, navigate to the point, centering the crosshair at the location and press enter.'\n })\n\n // Enable the interact plugin\n interactPlugin.enable()\n }\n )\n}\n\n/**\n * @import { InteractiveMap, InteractiveMapInitConfig, MapCenter, MapLibreMap, MapsEnvironmentConfig } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA,SACEA,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,wBAAwB,EACxBC,wBAAwB,EACxBC,kBAAkB,EAClBC,kBAAkB;AAGpB,MAAMC,uBAAuB,GAAG,mBAAmB;;AA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BAAgB,CAACiB,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QACtC;MACF,KAAK,sBAAsB;QACzBU,wBAAwB,CAACM,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QAC9C;MACF,KAAK,gBAAgB;QACnBY,kBAAkB,CAACI,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QACxC;MACF;QACE,MAAM,IAAIrD,KAAK,CAAC,iBAAiB,CAAC;IACtC;;IAEA;IACAqD,GAAG,CAACgC,QAAQ,CAAC,MAAM,EAAE;MACnBC,SAAS,EAAE,IAAI;MACfC,KAAK,EAAE,oBAAoB;MAC3BC,MAAM,EAAE;QACNC,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDC,MAAM,EAAE;QACNJ,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDE,OAAO,EAAE;QACPL,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDG,IAAI,EAAE;IACR,CAAC,CAAC;;IAEF;IACAb,cAAc,CAACc,MAAM,CAAC,CAAC;EACzB,CACF,CAAC;AACH;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"location-map.js","names":["EVENTS","centerMap","createMap","defaultConfig","eastingNorthingToLatLong","latLongToEastingNorthing","latLongToOsGridRef","osGridRefToLatLong","LOCATION_FIELD_SELECTOR","getInitMapConfig","locationField","locationType","dataset","locationtype","getInitLatLongMapConfig","getInitEastingNorthingMapConfig","getInitOsGridRefMapConfig","Error","validateLatLong","strLat","strLong","lat","trim","Number","long","valid","latMin","latMax","longMin","longMax","latInBounds","longInBounds","value","validateEastingNorthing","strEasting","strNorthing","easting","northing","eastingMin","eastingMax","northingMin","northingMax","validateOsGridRef","osGridRef","pattern","match","exec","getLatLongInputs","inputs","querySelectorAll","length","latInput","longInput","getEastingNorthingInputs","eastingInput","northingInput","getOsGridRefInput","input","querySelector","getInitMapCenterConfig","center","zoom","markers","id","coords","result","undefined","latlong","osGridRefInput","bindLatLongField","map","mapProvider","on","interactMarkerChange","onInteractMarkerChange","e","maxPrecision","toFixed","onUpdateInputs","addEventListener","bindEastingNorthingField","point","bindOsGridRefField","onUpdateInput","processLocation","config","location","index","HTMLDivElement","locationInputs","supportedLocations","includes","mapContainer","document","createElement","mapId","setAttribute","initConfig","after","interactPlugin","mapReady","onMapReady","addPanel","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","html","enable"],"sources":["../../../src/client/javascripts/location-map.js"],"sourcesContent":["import {\n EVENTS,\n centerMap,\n createMap,\n defaultConfig,\n eastingNorthingToLatLong,\n latLongToEastingNorthing,\n latLongToOsGridRef,\n osGridRefToLatLong\n} from '~/src/client/javascripts/map.js'\n\nconst LOCATION_FIELD_SELECTOR = 'input.govuk-input'\n\n/**\n * Gets initial map config for a location field\n * @param {HTMLDivElement} locationField - the location field element\n */\nfunction getInitMapConfig(locationField) {\n const locationType = locationField.dataset.locationtype\n\n switch (locationType) {\n case 'latlongfield':\n return getInitLatLongMapConfig(locationField)\n case 'eastingnorthingfield':\n return getInitEastingNorthingMapConfig(locationField)\n case 'osgridreffield':\n return getInitOsGridRefMapConfig(locationField)\n default:\n throw new Error('Not implemented')\n }\n}\n\n/**\n * Validates lat and long is numeric and within UK bounds\n * @param {string} strLat - the latitude string\n * @param {string} strLong - the longitude string\n * @returns {{ valid: false } | { valid: true, value: { lat: number, long: number } }}\n */\nfunction validateLatLong(strLat, strLong) {\n const lat = strLat.trim() && Number(strLat.trim())\n const long = strLong.trim() && Number(strLong.trim())\n\n if (!lat || !long) {\n return { valid: false }\n }\n\n const latMin = 49.85\n const latMax = 60.859\n const longMin = -13.687\n const longMax = 1.767\n\n const latInBounds = lat >= latMin && lat <= latMax\n const longInBounds = long >= longMin && long <= longMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { lat, long } }\n}\n\n/**\n * Validates easting and northing is numeric and within UK bounds\n * @param {string} strEasting - the easting string\n * @param {string} strNorthing - the northing string\n * @returns {{ valid: false } | { valid: true, value: { easting: number, northing: number } }}\n */\nfunction validateEastingNorthing(strEasting, strNorthing) {\n const easting = strEasting.trim() && Number(strEasting.trim())\n const northing = strNorthing.trim() && Number(strNorthing.trim())\n\n if (!easting || !northing) {\n return { valid: false }\n }\n\n const eastingMin = 0\n const eastingMax = 700000\n const northingMin = 0\n const northingMax = 1300000\n\n const latInBounds = easting >= eastingMin && easting <= eastingMax\n const longInBounds = northing >= northingMin && northing <= northingMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { easting, northing } }\n}\n\n/**\n * Validates OS grid reference is correct\n * @param {string} osGridRef - the OsGridRef\n * @returns {{ valid: false } | { valid: true, value: string }}\n */\nfunction validateOsGridRef(osGridRef) {\n if (!osGridRef) {\n return { valid: false }\n }\n\n const pattern =\n /^((([sS]|[nN])[a-hA-Hj-zJ-Z])|(([tT]|[oO])[abfglmqrvwABFGLMQRVW])|([hH][l-zL-Z])|([jJ][lmqrvwLMQRVW]))\\s?(([0-9]{3})\\s?([0-9]{3})|([0-9]{4})\\s?([0-9]{4})|([0-9]{5})\\s?([0-9]{5}))$/\n\n const match = pattern.exec(osGridRef)\n\n if (match === null) {\n return { valid: false }\n }\n\n return { valid: true, value: match[0] }\n}\n\n/**\n * Gets the inputs for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n */\nfunction getLatLongInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for lat and long')\n }\n\n const latInput = /** @type {HTMLInputElement} */ (inputs[0])\n const longInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { latInput, longInput }\n}\n\n/**\n * Gets the inputs for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n */\nfunction getEastingNorthingInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for easting and northing')\n }\n\n const eastingInput = /** @type {HTMLInputElement} */ (inputs[0])\n const northingInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { eastingInput, northingInput }\n}\n\n/**\n * Gets the input for a OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n */\nfunction getOsGridRefInput(locationField) {\n const input = locationField.querySelector(LOCATION_FIELD_SELECTOR)\n\n if (input === null) {\n throw new Error('Expected 1 input for osgridref')\n }\n\n return /** @type {HTMLInputElement} */ (input)\n}\n\n/**\n * Get the initial map config for a center point\n * @param {MapCenter} center - the point\n */\nfunction getInitMapCenterConfig(center) {\n return {\n zoom: '16',\n center,\n markers: [\n {\n id: 'location',\n coords: center\n }\n ]\n }\n}\n\n/**\n * Gets initial map config for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitLatLongMapConfig(locationField) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitEastingNorthingMapConfig(locationField) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for an OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitOsGridRefMapConfig(locationField) {\n const osGridRefInput = getOsGridRefInput(locationField)\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Bind a latlong field to the map\n * @param {HTMLDivElement} locationField - the latlong location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindLatLongField(locationField, map, mapProvider) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 7\n latInput.value = e.coords[1].toFixed(maxPrecision)\n longInput.value = e.coords[0].toFixed(maxPrecision)\n }\n )\n\n /**\n * Lat & long input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (result.valid) {\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n latInput.addEventListener('change', onUpdateInputs, false)\n longInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an eastingnorthing field to the map\n * @param {HTMLDivElement} locationField - the eastingnorthing location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindEastingNorthingField(locationField, map, mapProvider) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 0\n const point = latLongToEastingNorthing({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n eastingInput.value = point.easting.toFixed(maxPrecision)\n northingInput.value = point.northing.toFixed(maxPrecision)\n }\n )\n\n /**\n * Easting & northing input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (result.valid) {\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n eastingInput.addEventListener('change', onUpdateInputs, false)\n northingInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an OS grid reference field to the map\n * @param {HTMLDivElement} locationField - the osgridref location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindOsGridRefField(locationField, map, mapProvider) {\n const osGridRefInput = getOsGridRefInput(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const point = latLongToOsGridRef({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n osGridRefInput.value = point\n }\n )\n\n /**\n * OS grid reference input change event listener\n * Update the map view location when the input is changed\n */\n function onUpdateInput() {\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (result.valid) {\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n osGridRefInput.addEventListener('change', onUpdateInput, false)\n}\n\n/**\n * Processes a location field to add map capability\n * @param {MapsEnvironmentConfig} config - the location field element\n * @param {Element} location - the location field element\n * @param {number} index - the 0-based index\n */\nexport function processLocation(config, location, index) {\n if (!(location instanceof HTMLDivElement)) {\n return\n }\n\n const locationInputs = location.querySelector('.app-location-field-inputs')\n if (!(locationInputs instanceof HTMLDivElement)) {\n return\n }\n const locationType = location.dataset.locationtype\n\n // Check for support\n const supportedLocations = [\n 'latlongfield',\n 'eastingnorthingfield',\n 'osgridreffield'\n ]\n if (!locationType || !supportedLocations.includes(locationType)) {\n return\n }\n\n const mapContainer = document.createElement('div')\n const mapId = `map_${index}`\n\n mapContainer.setAttribute('id', mapId)\n mapContainer.setAttribute('class', 'map-container')\n\n const initConfig = getInitMapConfig(location) ?? defaultConfig\n\n locationInputs.after(mapContainer)\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n\n map.on(\n EVENTS.mapReady,\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n function onMapReady(e) {\n switch (locationType) {\n case 'latlongfield':\n bindLatLongField(location, map, e.map)\n break\n case 'eastingnorthingfield':\n bindEastingNorthingField(location, map, e.map)\n break\n case 'osgridreffield':\n bindOsGridRefField(location, map, e.map)\n break\n default:\n throw new Error('Not implemented')\n }\n\n // Add info panel\n map.addPanel('info', {\n showLabel: true,\n label: 'How to use the map',\n mobile: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n tablet: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n desktop: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n html: 'If using a map click on a point to update the location.<br><br>If using a keyboard, navigate to the point, centering the crosshair at the location and press enter.'\n })\n\n // Enable the interact plugin\n interactPlugin.enable()\n }\n )\n}\n\n/**\n * @import { InteractiveMap, InteractiveMapInitConfig, MapCenter, MapLibreMap, MapsEnvironmentConfig } from '~/src/client/javascripts/map.js'\n */\n"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AEpEf,GAAG,CAACE,EAAE,CACJxE,MAAM,CAACoG,QAAQ;EACf;AACJ;AACA;AACA;AACA;EACI,SAASC,UAAUA,CAAC1B,CAAC,EAAE;IACrB,QAAQhE,YAAY;MAClB,KAAK,cAAc;QACjB0D,gBAAgB,CAACiB,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QACtC;MACF,KAAK,sBAAsB;QACzBU,wBAAwB,CAACM,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QAC9C;MACF,KAAK,gBAAgB;QACnBY,kBAAkB,CAACI,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QACxC;MACF;QACE,MAAM,IAAIrD,KAAK,CAAC,iBAAiB,CAAC;IACtC;;IAEA;IACAqD,GAAG,CAACgC,QAAQ,CAAC,MAAM,EAAE;MACnBC,SAAS,EAAE,IAAI;MACfC,KAAK,EAAE,oBAAoB;MAC3BC,MAAM,EAAE;QACNC,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDC,MAAM,EAAE;QACNJ,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDE,OAAO,EAAE;QACPL,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDG,IAAI,EAAE;IACR,CAAC,CAAC;;IAEF;IACAb,cAAc,CAACc,MAAM,CAAC,CAAC;EACzB,CACF,CAAC;AACH;;AAEA;AACA;AACA","ignoreList":[]}
@@ -101,6 +101,12 @@ export namespace EVENTS {
101
101
  let drawEdited: string;
102
102
  let drawCancelled: string;
103
103
  }
104
+ export function transformGeocodeRequest(request: {
105
+ url: string;
106
+ options: {
107
+ method: "get";
108
+ };
109
+ }): Request;
104
110
  /**
105
111
  * - an instance of a InteractiveMap
106
112
  */
@@ -235,6 +235,18 @@ export function makeTileRequestTransformer(apiPath) {
235
235
  };
236
236
  }
237
237
 
238
+ /**
239
+ * Temporary transform request function to transform geocode requests. Fixed in v0.0.18 of interactive map so this is not needed when we upgrade.
240
+ * @param {object} request
241
+ * @param {string} request.url
242
+ * @param {{ method: 'get' }} request.options
243
+ * @returns {Request}
244
+ */
245
+ export const transformGeocodeRequest = request => {
246
+ const url = new URL(request.url, window.location.origin);
247
+ return new Request(url.toString(), request.options);
248
+ };
249
+
238
250
  /**
239
251
  * Create a Defra map instance
240
252
  * @param {string} mapId - the map id
@@ -305,6 +317,7 @@ export function createMap(mapId, initConfig, mapsConfig) {
305
317
  attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`
306
318
  }]
307
319
  }), interactPlugin, defra.searchPlugin({
320
+ transformRequest: transformGeocodeRequest,
308
321
  osNamesURL: `${apiPath}/geocode-proxy?query={query}`,
309
322
  width: '300px',
310
323
  showMarker: false
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","names":["centroid","OsGridRef","LatLon","processGeospatial","processLocation","DEFAULT_LAT","DEFAULT_LONG","COMPANY_SYMBOL_CODE","defaultData","VTS_OUTDOOR_URL","VTS_DARK_URL","VTS_BLACK_AND_WHITE_URL","latLongToEastingNorthing","lat","long","point","toOsGrid","eastingNorthingToLatLong","easting","northing","latLong","toLatLon","latitude","longitude","latLongToOsGridRef","toString","osGridRefToLatLong","osGridRef","parse","getCoordinateGridRef","feature","geometry","type","coordinates","getCentroidGridRef","centre","defaultConfig","zoom","center","EVENTS","mapReady","interactMarkerChange","drawReady","drawCreated","drawEdited","drawCancelled","formSubmitFactory","buttons","onFormSubmit","e","submitter","HTMLButtonElement","includes","preventDefault","initMaps","config","assetPath","apiPath","data","locations","document","querySelectorAll","geospatials","length","form","closest","Array","from","addEventListener","forEach","location","index","geospatial","makeTileRequestTransformer","transformTileRequest","url","resourceType","startsWith","replace","window","origin","headers","encodeURIComponent","spritesPath","path","substring","createMap","mapId","initConfig","mapsConfig","logoAltText","defra","interactPlugin","markerColor","outdoor","dark","interactionMode","multiSelect","map","InteractiveMap","enableFullscreen","autoColorScheme","mapProvider","maplibreProvider","reverseGeocodeProvider","openNamesProvider","behaviour","minZoom","maxZoom","containerHeight","enableZoomControls","transformRequest","plugins","mapStylesPlugin","mapStyles","id","label","thumbnail","logo","attribution","String","fromCodePoint","Date","getFullYear","backgroundColor","mapColorScheme","appColorScheme","searchPlugin","osNamesURL","width","showMarker","scaleBarPlugin","units","centerMap","addMarker","flyTo","essential"],"sources":["../../../src/client/javascripts/map.js"],"sourcesContent":["import { centroid } from '@turf/centroid'\n// @ts-expect-error - no types\nimport OsGridRef, { LatLon } from 'geodesy/osgridref.js'\n\nimport { processGeospatial } from '~/src/client/javascripts/geospatial-map.js'\nimport { processLocation } from '~/src/client/javascripts/location-map.js'\n\n// Center of UK\nconst DEFAULT_LAT = 53.825564\nconst DEFAULT_LONG = -2.421975\nconst COMPANY_SYMBOL_CODE = 169\n\nconst defaultData = {\n VTS_OUTDOOR_URL: '/api/maps/vts/OS_VTS_3857_Outdoor.json',\n VTS_DARK_URL: '/api/maps/vts/OS_VTS_3857_Dark.json',\n VTS_BLACK_AND_WHITE_URL: '/api/maps/vts/OS_VTS_3857_Black_and_White.json'\n}\n\n/**\n * Converts lat long to easting and northing\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {{ easting: number, northing: number }}\n */\nexport function latLongToEastingNorthing({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid()\n}\n\n/**\n * Converts easting and northing to lat long\n * @param {object} param\n * @param {number} param.easting\n * @param {number} param.northing\n * @returns {{ lat: number, long: number }}\n */\nexport function eastingNorthingToLatLong({ easting, northing }) {\n const point = new OsGridRef(easting, northing)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n/**\n * Converts lat long to an ordnance survey grid reference\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {string}\n */\nexport function latLongToOsGridRef({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n}\n\n/**\n * Converts an ordnance survey grid reference to lat long\n * @param {string} osGridRef\n * @returns {{ lat: number, long: number }}\n */\nexport function osGridRefToLatLong(osGridRef) {\n const point = OsGridRef.parse(osGridRef)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n/**\n * Get the grid ref from the first coordinate of a long/lat feature\n * @param {Feature} feature\n */\nexport function getCoordinateGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else if (feature.geometry.type === 'LineString') {\n const [long, lat] = feature.geometry.coordinates[0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const [long, lat] = feature.geometry.coordinates[0][0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/**\n * Get the centroid grid ref from a long/lat feature\n * @param {Feature} feature\n */\nexport function getCentroidGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const centre = centroid(feature)\n const [long, lat] = centre.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/** @type {InteractiveMapInitConfig} */\nexport const defaultConfig = {\n zoom: '6',\n center: [DEFAULT_LONG, DEFAULT_LAT]\n}\n\nexport const EVENTS = {\n mapReady: 'map:ready',\n interactMarkerChange: 'interact:markerchange',\n drawReady: 'draw:ready',\n drawCreated: 'draw:created',\n drawEdited: 'draw:edited',\n drawCancelled: 'draw:cancelled'\n}\n\n/**\n * Make a form submit handler that only allows submissions from allowed buttons\n * @param {HTMLButtonElement[]} buttons - the form buttons to allow submissions\n */\nexport function formSubmitFactory(buttons) {\n /**\n * The submit handler\n * @param {SubmitEvent} e\n */\n const onFormSubmit = function (e) {\n if (\n !(e.submitter instanceof HTMLButtonElement) ||\n !buttons.includes(e.submitter)\n ) {\n e.preventDefault()\n }\n }\n\n return onFormSubmit\n}\n\n/**\n * Initialise location maps\n * @param {Partial<MapsEnvironmentConfig>} config - the map configuration\n */\nexport function initMaps(config = {}) {\n const {\n assetPath = '/assets',\n apiPath = '/form/api',\n data = defaultData\n } = config\n const locations = document.querySelectorAll('.app-location-field')\n const geospatials = document.querySelectorAll('.app-geospatial-field')\n\n // TODO: Fix this in `interactive-map`\n // If there are location components on the page fix up the main form submit\n // handler so it doesn't fire when using the integrated map search feature\n if (locations.length) {\n const form = locations[0].closest('form')\n\n if (form === null) {\n return\n }\n\n const buttons = Array.from(form.querySelectorAll('button'))\n form.addEventListener('submit', formSubmitFactory(buttons), false)\n }\n\n if (geospatials.length) {\n const form = geospatials[0].closest('form')\n\n if (form === null) {\n return\n }\n\n const buttons = Array.from(form.querySelectorAll('button'))\n form.addEventListener('submit', formSubmitFactory(buttons), false)\n }\n\n locations.forEach((location, index) => {\n processLocation({ assetPath, apiPath, data }, location, index)\n })\n\n geospatials.forEach((geospatial, index) => {\n processGeospatial({ assetPath, apiPath, data }, geospatial, index)\n })\n}\n\n/**\n * OS API request proxy factory\n * @param {string} apiPath - the root API path\n */\nexport function makeTileRequestTransformer(apiPath) {\n /**\n * Proxy OS API requests via our server\n * @param {string} url - the request URL\n * @param {string} resourceType - the resource type\n */\n return function transformTileRequest(url, resourceType) {\n if (url.startsWith('https://api.os.uk')) {\n if (resourceType === 'Tile') {\n return {\n url: url.replace(\n 'https://api.os.uk/maps/vector/v1/vts',\n `${window.location.origin}${apiPath}`\n ),\n headers: {}\n }\n }\n\n if (resourceType !== 'Style') {\n return {\n url: `${apiPath}/map-proxy?url=${encodeURIComponent(url)}`,\n headers: {}\n }\n }\n }\n\n const spritesPath =\n 'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main'\n\n // Proxy sprite requests\n if (url.startsWith(spritesPath)) {\n const path = url.substring(spritesPath.length)\n return {\n url: `${apiPath}/maps/vts${path}`,\n headers: {}\n }\n }\n\n return { url, headers: {} }\n }\n}\n\n/**\n * Create a Defra map instance\n * @param {string} mapId - the map id\n * @param {InteractiveMapInitConfig} initConfig - the map initial configuration\n * @param {MapsEnvironmentConfig} mapsConfig - the map environment params\n */\nexport function createMap(mapId, initConfig, mapsConfig) {\n const { assetPath, apiPath, data = defaultData } = mapsConfig\n const logoAltText = 'Ordnance survey logo'\n\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n const interactPlugin = defra.interactPlugin({\n markerColor: { outdoor: '#ff0000', dark: '#00ff00' },\n interactionMode: 'marker',\n multiSelect: false\n })\n\n /** @type {InteractiveMap} */\n const map = new defra.InteractiveMap(mapId, {\n enableFullscreen: true,\n autoColorScheme: false,\n mapProvider: defra.maplibreProvider(),\n reverseGeocodeProvider: defra.openNamesProvider({\n url: `${apiPath}/reverse-geocode-proxy?easting={easting}&northing={northing}`\n }),\n behaviour: 'inline',\n minZoom: 6,\n maxZoom: 18,\n containerHeight: '400px',\n enableZoomControls: true,\n transformRequest: makeTileRequestTransformer(apiPath),\n ...initConfig,\n plugins: [\n defra.mapStylesPlugin({\n mapStyles: [\n {\n id: 'outdoor',\n label: 'Outdoor',\n url: data.VTS_OUTDOOR_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/outdoor-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`,\n backgroundColor: '#f5f5f0'\n },\n {\n id: 'dark',\n label: 'Dark',\n url: data.VTS_DARK_URL,\n mapColorScheme: 'dark',\n appColorScheme: 'dark',\n thumbnail: `${assetPath}/interactive-map/assets/images/dark-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-white.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n },\n {\n id: 'black-and-white',\n label: 'Black/White',\n url: data.VTS_BLACK_AND_WHITE_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/black-and-white-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-black.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n }\n ]\n }),\n interactPlugin,\n defra.searchPlugin({\n osNamesURL: `${apiPath}/geocode-proxy?query={query}`,\n width: '300px',\n showMarker: false\n }),\n defra.scaleBarPlugin({\n units: 'metric'\n }),\n ...(initConfig.plugins ?? [])\n ]\n })\n\n return { map, interactPlugin }\n}\n\n/**\n * Updates the marker position and moves the map view port the new location\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n * @param {MapCenter} center - the point\n */\nexport function centerMap(map, mapProvider, center) {\n // Move the 'location' marker to the new point\n map.addMarker('location', center)\n\n // Pan & zoom the map to the new valid location\n mapProvider.flyTo({\n center,\n zoom: 14,\n essential: true\n })\n}\n\n/**\n * @typedef {object} InteractiveMap - an instance of a InteractiveMap\n * @property {Function} on - register callback listeners to map events\n * @property {Function} addPanel - adds a new panel to the map\n * @property {Function} addMarker - adds/updates a marker\n * @property {Function} removeMarker - removes a marker\n * @property {Function} addButton - adds/updates a button\n * @property {Function} toggleButtonState - toggle the state of a button\n */\n\n/**\n * @typedef {object} MapLibreMap\n * @property {Function} flyTo - pans/zooms to a new location\n * @property {Function} fitBounds - fits the my to the new bounds\n */\n\n/**\n * @typedef {[number, number]} MapCenter - Map center point as [long, lat]\n */\n\n/**\n * @typedef {object} InteractiveMapInitConfig - additional config that can be provided to InteractiveMap\n * @property {string} zoom - the zoom level of the map\n * @property {MapCenter} center - the center point of the map\n * @property {{ id: string, coords: MapCenter }[]} [markers] - the markers to add to the map\n * @property {any[]} [plugins] - additional plugins\n */\n\n/**\n * @typedef {object} TileData\n * @property {string} VTS_OUTDOOR_URL - the outdoor tile URL\n * @property {string} VTS_DARK_URL - the dark tile URL\n * @property {string} VTS_BLACK_AND_WHITE_URL - the black and white tile URL\n */\n\n/**\n * @typedef {object} MapsEnvironmentConfig\n * @property {string} assetPath - the root asset path\n * @property {string} apiPath - the root API path\n * @property {TileData} data - the tile data config\n */\n\n/**\n * @import { Feature } from '~/src/server/plugins/engine/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC;AACA,OAAOC,SAAS,IAAIC,MAAM,QAAQ,sBAAsB;AAExD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;;AAExB;AACA,MAAMC,WAAW,GAAG,SAAS;AAC7B,MAAMC,YAAY,GAAG,CAAC,QAAQ;AAC9B,MAAMC,mBAAmB,GAAG,GAAG;AAE/B,MAAMC,WAAW,GAAG;EAClBC,eAAe,EAAE,wCAAwC;EACzDC,YAAY,EAAE,qCAAqC;EACnDC,uBAAuB,EAAE;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAC;EAAEC,GAAG;EAAEC;AAAK,CAAC,EAAE;EACtD,MAAMC,KAAK,GAAG,IAAIb,MAAM,CAACW,GAAG,EAAEC,IAAI,CAAC;EAEnC,OAAOC,KAAK,CAACC,QAAQ,CAAC,CAAC;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAC;EAAEC,OAAO;EAAEC;AAAS,CAAC,EAAE;EAC9D,MAAMJ,KAAK,GAAG,IAAId,SAAS,CAACiB,OAAO,EAAEC,QAAQ,C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E,oBAAoBC,MAAM,CAACC,aAAa,CAAClH,mBAAmB,CAAC,wCAAwC,IAAImH,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;MAC5I,CAAC;IAEL,CAAC,CAAC,EACF/B,cAAc,EACdD,KAAK,CAACoC,YAAY,CAAC;MACjBC,UAAU,EAAE,GAAGvE,OAAO,8BAA8B;MACpDwE,KAAK,EAAE,OAAO;MACdC,UAAU,EAAE;IACd,CAAC,CAAC,EACFvC,KAAK,CAACwC,cAAc,CAAC;MACnBC,KAAK,EAAE;IACT,CAAC,CAAC,EACF,IAAI5C,UAAU,CAACwB,OAAO,IAAI,EAAE,CAAC;EAEjC,CAAC,CAAC;EAEF,OAAO;IAAEd,GAAG;IAAEN;EAAe,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyC,SAASA,CAACnC,GAAG,EAAEI,WAAW,EAAEhE,MAAM,EAAE;EAClD;EACA4D,GAAG,CAACoC,SAAS,CAAC,UAAU,EAAEhG,MAAM,CAAC;;EAEjC;EACAgE,WAAW,CAACiC,KAAK,CAAC;IAChBjG,MAAM;IACND,IAAI,EAAE,EAAE;IACRmG,SAAS,EAAE;EACb,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"map.js","names":["centroid","OsGridRef","LatLon","processGeospatial","processLocation","DEFAULT_LAT","DEFAULT_LONG","COMPANY_SYMBOL_CODE","defaultData","VTS_OUTDOOR_URL","VTS_DARK_URL","VTS_BLACK_AND_WHITE_URL","latLongToEastingNorthing","lat","long","point","toOsGrid","eastingNorthingToLatLong","easting","northing","latLong","toLatLon","latitude","longitude","latLongToOsGridRef","toString","osGridRefToLatLong","osGridRef","parse","getCoordinateGridRef","feature","geometry","type","coordinates","getCentroidGridRef","centre","defaultConfig","zoom","center","EVENTS","mapReady","interactMarkerChange","drawReady","drawCreated","drawEdited","drawCancelled","formSubmitFactory","buttons","onFormSubmit","e","submitter","HTMLButtonElement","includes","preventDefault","initMaps","config","assetPath","apiPath","data","locations","document","querySelectorAll","geospatials","length","form","closest","Array","from","addEventListener","forEach","location","index","geospatial","makeTileRequestTransformer","transformTileRequest","url","resourceType","startsWith","replace","window","origin","headers","encodeURIComponent","spritesPath","path","substring","transformGeocodeRequest","request","URL","Request","options","createMap","mapId","initConfig","mapsConfig","logoAltText","defra","interactPlugin","markerColor","outdoor","dark","interactionMode","multiSelect","map","InteractiveMap","enableFullscreen","autoColorScheme","mapProvider","maplibreProvider","reverseGeocodeProvider","openNamesProvider","behaviour","minZoom","maxZoom","containerHeight","enableZoomControls","transformRequest","plugins","mapStylesPlugin","mapStyles","id","label","thumbnail","logo","attribution","String","fromCodePoint","Date","getFullYear","backgroundColor","mapColorScheme","appColorScheme","searchPlugin","osNamesURL","width","showMarker","scaleBarPlugin","units","centerMap","addMarker","flyTo","essential"],"sources":["../../../src/client/javascripts/map.js"],"sourcesContent":["import { centroid } from '@turf/centroid'\n// @ts-expect-error - no types\nimport OsGridRef, { LatLon } from 'geodesy/osgridref.js'\n\nimport { processGeospatial } from '~/src/client/javascripts/geospatial-map.js'\nimport { processLocation } from '~/src/client/javascripts/location-map.js'\n\n// Center of UK\nconst DEFAULT_LAT = 53.825564\nconst DEFAULT_LONG = -2.421975\nconst COMPANY_SYMBOL_CODE = 169\n\nconst defaultData = {\n VTS_OUTDOOR_URL: '/api/maps/vts/OS_VTS_3857_Outdoor.json',\n VTS_DARK_URL: '/api/maps/vts/OS_VTS_3857_Dark.json',\n VTS_BLACK_AND_WHITE_URL: '/api/maps/vts/OS_VTS_3857_Black_and_White.json'\n}\n\n/**\n * Converts lat long to easting and northing\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {{ easting: number, northing: number }}\n */\nexport function latLongToEastingNorthing({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid()\n}\n\n/**\n * Converts easting and northing to lat long\n * @param {object} param\n * @param {number} param.easting\n * @param {number} param.northing\n * @returns {{ lat: number, long: number }}\n */\nexport function eastingNorthingToLatLong({ easting, northing }) {\n const point = new OsGridRef(easting, northing)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n/**\n * Converts lat long to an ordnance survey grid reference\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {string}\n */\nexport function latLongToOsGridRef({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n}\n\n/**\n * Converts an ordnance survey grid reference to lat long\n * @param {string} osGridRef\n * @returns {{ lat: number, long: number }}\n */\nexport function osGridRefToLatLong(osGridRef) {\n const point = OsGridRef.parse(osGridRef)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n/**\n * Get the grid ref from the first coordinate of a long/lat feature\n * @param {Feature} feature\n */\nexport function getCoordinateGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else if (feature.geometry.type === 'LineString') {\n const [long, lat] = feature.geometry.coordinates[0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const [long, lat] = feature.geometry.coordinates[0][0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/**\n * Get the centroid grid ref from a long/lat feature\n * @param {Feature} feature\n */\nexport function getCentroidGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const centre = centroid(feature)\n const [long, lat] = centre.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/** @type {InteractiveMapInitConfig} */\nexport const defaultConfig = {\n zoom: '6',\n center: [DEFAULT_LONG, DEFAULT_LAT]\n}\n\nexport const EVENTS = {\n mapReady: 'map:ready',\n interactMarkerChange: 'interact:markerchange',\n drawReady: 'draw:ready',\n drawCreated: 'draw:created',\n drawEdited: 'draw:edited',\n drawCancelled: 'draw:cancelled'\n}\n\n/**\n * Make a form submit handler that only allows submissions from allowed buttons\n * @param {HTMLButtonElement[]} buttons - the form buttons to allow submissions\n */\nexport function formSubmitFactory(buttons) {\n /**\n * The submit handler\n * @param {SubmitEvent} e\n */\n const onFormSubmit = function (e) {\n if (\n !(e.submitter instanceof HTMLButtonElement) ||\n !buttons.includes(e.submitter)\n ) {\n e.preventDefault()\n }\n }\n\n return onFormSubmit\n}\n\n/**\n * Initialise location maps\n * @param {Partial<MapsEnvironmentConfig>} config - the map configuration\n */\nexport function initMaps(config = {}) {\n const {\n assetPath = '/assets',\n apiPath = '/form/api',\n data = defaultData\n } = config\n const locations = document.querySelectorAll('.app-location-field')\n const geospatials = document.querySelectorAll('.app-geospatial-field')\n\n // TODO: Fix this in `interactive-map`\n // If there are location components on the page fix up the main form submit\n // handler so it doesn't fire when using the integrated map search feature\n if (locations.length) {\n const form = locations[0].closest('form')\n\n if (form === null) {\n return\n }\n\n const buttons = Array.from(form.querySelectorAll('button'))\n form.addEventListener('submit', formSubmitFactory(buttons), false)\n }\n\n if (geospatials.length) {\n const form = geospatials[0].closest('form')\n\n if (form === null) {\n return\n }\n\n const buttons = Array.from(form.querySelectorAll('button'))\n form.addEventListener('submit', formSubmitFactory(buttons), false)\n }\n\n locations.forEach((location, index) => {\n processLocation({ assetPath, apiPath, data }, location, index)\n })\n\n geospatials.forEach((geospatial, index) => {\n processGeospatial({ assetPath, apiPath, data }, geospatial, index)\n })\n}\n\n/**\n * OS API request proxy factory\n * @param {string} apiPath - the root API path\n */\nexport function makeTileRequestTransformer(apiPath) {\n /**\n * Proxy OS API requests via our server\n * @param {string} url - the request URL\n * @param {string} resourceType - the resource type\n */\n return function transformTileRequest(url, resourceType) {\n if (url.startsWith('https://api.os.uk')) {\n if (resourceType === 'Tile') {\n return {\n url: url.replace(\n 'https://api.os.uk/maps/vector/v1/vts',\n `${window.location.origin}${apiPath}`\n ),\n headers: {}\n }\n }\n\n if (resourceType !== 'Style') {\n return {\n url: `${apiPath}/map-proxy?url=${encodeURIComponent(url)}`,\n headers: {}\n }\n }\n }\n\n const spritesPath =\n 'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main'\n\n // Proxy sprite requests\n if (url.startsWith(spritesPath)) {\n const path = url.substring(spritesPath.length)\n return {\n url: `${apiPath}/maps/vts${path}`,\n headers: {}\n }\n }\n\n return { url, headers: {} }\n }\n}\n\n/**\n * Temporary transform request function to transform geocode requests. Fixed in v0.0.18 of interactive map so this is not needed when we upgrade.\n * @param {object} request\n * @param {string} request.url\n * @param {{ method: 'get' }} request.options\n * @returns {Request}\n */\nexport const transformGeocodeRequest = (request) => {\n const url = new URL(request.url, window.location.origin)\n return new Request(url.toString(), request.options)\n}\n\n/**\n * Create a Defra map instance\n * @param {string} mapId - the map id\n * @param {InteractiveMapInitConfig} initConfig - the map initial configuration\n * @param {MapsEnvironmentConfig} mapsConfig - the map environment params\n */\nexport function createMap(mapId, initConfig, mapsConfig) {\n const { assetPath, apiPath, data = defaultData } = mapsConfig\n const logoAltText = 'Ordnance survey logo'\n\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n const interactPlugin = defra.interactPlugin({\n markerColor: { outdoor: '#ff0000', dark: '#00ff00' },\n interactionMode: 'marker',\n multiSelect: false\n })\n\n /** @type {InteractiveMap} */\n const map = new defra.InteractiveMap(mapId, {\n enableFullscreen: true,\n autoColorScheme: false,\n mapProvider: defra.maplibreProvider(),\n reverseGeocodeProvider: defra.openNamesProvider({\n url: `${apiPath}/reverse-geocode-proxy?easting={easting}&northing={northing}`\n }),\n behaviour: 'inline',\n minZoom: 6,\n maxZoom: 18,\n containerHeight: '400px',\n enableZoomControls: true,\n transformRequest: makeTileRequestTransformer(apiPath),\n ...initConfig,\n plugins: [\n defra.mapStylesPlugin({\n mapStyles: [\n {\n id: 'outdoor',\n label: 'Outdoor',\n url: data.VTS_OUTDOOR_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/outdoor-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`,\n backgroundColor: '#f5f5f0'\n },\n {\n id: 'dark',\n label: 'Dark',\n url: data.VTS_DARK_URL,\n mapColorScheme: 'dark',\n appColorScheme: 'dark',\n thumbnail: `${assetPath}/interactive-map/assets/images/dark-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-white.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n },\n {\n id: 'black-and-white',\n label: 'Black/White',\n url: data.VTS_BLACK_AND_WHITE_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/black-and-white-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-black.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n }\n ]\n }),\n interactPlugin,\n defra.searchPlugin({\n transformRequest: transformGeocodeRequest,\n osNamesURL: `${apiPath}/geocode-proxy?query={query}`,\n width: '300px',\n showMarker: false\n }),\n defra.scaleBarPlugin({\n units: 'metric'\n }),\n ...(initConfig.plugins ?? [])\n ]\n })\n\n return { map, interactPlugin }\n}\n\n/**\n * Updates the marker position and moves the map view port the new location\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n * @param {MapCenter} center - the point\n */\nexport function centerMap(map, mapProvider, center) {\n // Move the 'location' marker to the new point\n map.addMarker('location', center)\n\n // Pan & zoom the map to the new valid location\n mapProvider.flyTo({\n center,\n zoom: 14,\n essential: true\n })\n}\n\n/**\n * @typedef {object} InteractiveMap - an instance of a InteractiveMap\n * @property {Function} on - register callback listeners to map events\n * @property {Function} addPanel - adds a new panel to the map\n * @property {Function} addMarker - adds/updates a marker\n * @property {Function} removeMarker - removes a marker\n * @property {Function} addButton - adds/updates a button\n * @property {Function} toggleButtonState - toggle the state of a button\n */\n\n/**\n * @typedef {object} MapLibreMap\n * @property {Function} flyTo - pans/zooms to a new location\n * @property {Function} fitBounds - fits the my to the new bounds\n */\n\n/**\n * @typedef {[number, number]} MapCenter - Map center point as [long, lat]\n */\n\n/**\n * @typedef {object} InteractiveMapInitConfig - additional config that can be provided to InteractiveMap\n * @property {string} zoom - the zoom level of the map\n * @property {MapCenter} center - the center point of the map\n * @property {{ id: string, coords: MapCenter }[]} [markers] - the markers to add to the map\n * @property {any[]} [plugins] - additional plugins\n */\n\n/**\n * @typedef {object} TileData\n * @property {string} VTS_OUTDOOR_URL - the outdoor tile URL\n * @property {string} VTS_DARK_URL - the dark tile URL\n * @property {string} VTS_BLACK_AND_WHITE_URL - the black and white tile URL\n */\n\n/**\n * @typedef {object} MapsEnvironmentConfig\n * @property {string} assetPath - the root asset path\n * @property {string} apiPath - the root API path\n * @property {TileData} data - the tile data config\n */\n\n/**\n * @import { Feature } from '~/src/server/plugins/engine/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC;AACA,OAAOC,SAAS,IAAIC,MAAM,QAAQ,sBAAsB;AAExD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;;AAExB;AACA,MAAMC,WAAW,GAAG,SAAS;AAC7B,MAAMC,YAAY,GAAG,CAAC,QAAQ;AAC9B,MAAMC,mBAAmB,GAAG,G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