@defra/interactive-map 0.0.31-alpha → 0.0.32-alpha
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.
- package/README.md +2 -2
- package/assets/images/bright-ofm-thumb.jpg +0 -0
- package/assets/images/dark-ofm-thumb.jpg +0 -0
- package/assets/images/road-ofm-thumb.jpg +0 -0
- package/assets/templates/add-polygons.njk +143 -0
- package/assets/templates/add-symbols.njk +119 -0
- package/assets/templates/{map.njk → basic-map.njk} +9 -17
- package/assets/templates/button-map.njk +56 -0
- package/assets/templates/draw-tools.njk +161 -0
- package/assets/templates/marker-panel.njk +91 -0
- package/assets/templates/place-marker.njk +104 -0
- package/assets/templates/search-control.njk +98 -0
- package/assets/templates/select-feature.njk +101 -0
- package/assets/templates/style-switcher.njk +87 -0
- package/assets/templates/toggle-marker-label.njk +74 -0
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api.md +55 -0
- package/docs/assets/css/docusaurus.scss +22 -6
- package/docs/assets/images/add-polygons.jpg +0 -0
- package/docs/assets/images/add-symbols.jpg +0 -0
- package/docs/assets/images/place-marker.jpg +0 -0
- package/docs/assets/images/screenshot.jpg +0 -0
- package/docs/examples/add-marker-with-panel.mdx +1 -1
- package/docs/examples/add-polygons.mdx +225 -0
- package/docs/examples/add-symbols.mdx +177 -0
- package/docs/examples/{draw.mdx → draw-tools.mdx} +2 -2
- package/docs/examples/index.mdx +38 -2
- package/docs/examples/place-marker.mdx +151 -0
- package/docs/plugins/datasets.md +144 -96
- package/docs/plugins/interact.md +1 -4
- package/docusaurus.config.cjs +5 -2
- package/govuk-prototype-kit.config.json +52 -2
- package/package.json +1 -1
- package/plugins/beta/datasets/dist/css/index.css +1 -2
- package/plugins/beta/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/index.js +1 -1
- package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +27 -9
- package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +46 -4
- package/plugins/beta/datasets/src/api/setFeatureVisibility.js +10 -1
- package/plugins/beta/datasets/src/api/setFeatureVisibility.test.js +48 -6
- package/plugins/beta/datasets/src/components/LayersMenu/Layers.module.scss +12 -12
- package/plugins/beta/datasets/src/reducers/datasetsToMenu.js +11 -6
- package/plugins/beta/datasets/src/reducers/datasetsToMenu.test.js +49 -0
- package/plugins/beta/datasets/src/reducers/mappedDatasetsReducer.js +8 -1
- package/plugins/beta/datasets/src/reducers/pluginState.js +1 -1
- package/plugins/beta/datasets/src/registry/dataset.js +7 -3
- package/plugins/beta/datasets/src/registry/dataset.test.js +14 -0
- package/plugins/beta/datasets/src/registry/dynamicGeoJson.js +1 -1
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/api/addFeature.js +12 -3
- package/plugins/beta/draw-es/src/events.js +8 -3
- package/plugins/beta/draw-es/src/events.test.js +2 -0
- package/plugins/beta/draw-es/src/graphic.js +26 -2
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/DrawInit.jsx +8 -0
- package/plugins/beta/draw-ml/src/api/newLine.js +1 -0
- package/plugins/beta/draw-ml/src/api/newPolygon.js +1 -0
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +21 -12
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +4 -0
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +4 -2
- package/plugins/beta/map-styles/src/mapStyles.scss +41 -41
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +1 -3
- package/plugins/interact/src/InteractInit.test.js +0 -2
- package/plugins/interact/src/events.test.js +1 -1
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +4 -10
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +5 -10
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -10
- package/plugins/interact/src/hooks/useHighlightSync.test.js +2 -21
- package/plugins/interact/src/hooks/useInteractionHandlers.js +5 -11
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -25
- package/plugins/interact/src/reducer.js +4 -22
- package/plugins/interact/src/reducer.test.js +11 -39
- package/plugins/search/dist/css/index.css +5 -2
- package/plugins/search/src/components/Form/Form.module.scss +5 -2
- package/plugins/search/src/search.scss +4 -4
- package/src/App/components/CrossHair/CrossHair.module.scss +8 -8
- package/src/App/hooks/useLayoutMeasurements.js +10 -2
- package/src/App/hooks/useResizeObserver.js +4 -2
- package/src/InteractiveMap/InteractiveMap.js +4 -4
- package/src/InteractiveMap/InteractiveMap.test.js +3 -3
- package/src/InteractiveMap/behaviourController.js +3 -1
- package/src/InteractiveMap/behaviourController.test.js +6 -3
- package/src/InteractiveMap/domStateManager.js +2 -0
- package/src/config/events.js +21 -3
- package/docs/assets/images/screens-blue.jpg +0 -0
- package/docs/assets/images/screens-white.jpg +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{% extends "layouts/main.html" %}
|
|
2
|
+
|
|
3
|
+
{% block pageTitle %}
|
|
4
|
+
Place a marker to continue – GOV.UK Prototype Kit
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block head %}
|
|
8
|
+
<link href="/public/stylesheets/application.css" rel="stylesheet" type="text/css">
|
|
9
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
10
|
+
{% endblock %}
|
|
11
|
+
|
|
12
|
+
{% block bodyStart %}
|
|
13
|
+
<script>document.body.classList.add('im-is-loading')</script>
|
|
14
|
+
{% endblock %}
|
|
15
|
+
|
|
16
|
+
{% block beforeContent %}
|
|
17
|
+
{{ govukBackLink({
|
|
18
|
+
text: "Back",
|
|
19
|
+
href: "javascript:window.history.back()"
|
|
20
|
+
}) }}
|
|
21
|
+
{% endblock %}
|
|
22
|
+
|
|
23
|
+
{% block content %}
|
|
24
|
+
<div class="govuk-grid-row">
|
|
25
|
+
<div class="govuk-grid-column-two-thirds">
|
|
26
|
+
|
|
27
|
+
<h1 class="govuk-heading-l">
|
|
28
|
+
Place a marker to continue
|
|
29
|
+
</h1>
|
|
30
|
+
|
|
31
|
+
<div id="map"></div>
|
|
32
|
+
|
|
33
|
+
<div id="external-buttons" hidden>
|
|
34
|
+
<button class="govuk-button govuk-!-margin-top-4" id="continue-btn" disabled>Continue</button>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
{% endblock %}
|
|
40
|
+
|
|
41
|
+
{% block pageScripts %}
|
|
42
|
+
<!-- Defra library scripts -->
|
|
43
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/dist/umd/index.js"></script>
|
|
44
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/providers/maplibre/dist/umd/index.js"></script>
|
|
45
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/plugins/interact/dist/umd/index.js"></script>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
var interactPlugin = defra.interactPlugin({
|
|
49
|
+
interactionModes: ['placeMarker']
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
var map = new defra.InteractiveMap('map', {
|
|
53
|
+
behaviour: 'hybrid',
|
|
54
|
+
mapProvider: defra.maplibreProvider(),
|
|
55
|
+
mapStyle: {
|
|
56
|
+
url: 'https://tiles.openfreemap.org/styles/liberty',
|
|
57
|
+
attribution: 'OpenFreeMap © OpenMapTiles Data from OpenStreetMap',
|
|
58
|
+
backgroundColor: '#f5f5f0'
|
|
59
|
+
},
|
|
60
|
+
center: [-0.1276, 51.5074],
|
|
61
|
+
zoom: 12,
|
|
62
|
+
containerHeight: '516px',
|
|
63
|
+
plugins: [interactPlugin],
|
|
64
|
+
backAndContinue: {
|
|
65
|
+
backLabel: 'Back',
|
|
66
|
+
continueLabel: 'Continue',
|
|
67
|
+
continueEnabledWhen: function (context) {
|
|
68
|
+
return context.mapState.markers.items.some(function (m) { return m.id === 'location' })
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
map.on('map:ready', function () {
|
|
74
|
+
interactPlugin.enable()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
map.on('app:continue', function (context) {
|
|
78
|
+
var marker = context.mapState.markers.items.find(function (m) { return m.id === 'location' })
|
|
79
|
+
// navigate to next step with marker.coords
|
|
80
|
+
if (marker) {
|
|
81
|
+
console.log('Continuing with marker at:', marker.coords)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
var continueBtn = document.getElementById('continue-btn')
|
|
86
|
+
var externalButtons = document.getElementById('external-buttons')
|
|
87
|
+
|
|
88
|
+
function setInline(isFullscreen) {
|
|
89
|
+
externalButtons.hidden = isFullscreen
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
map.on('app:opened', function (e) { setInline(e.isFullscreen) })
|
|
93
|
+
map.on('app:closed', function () { externalButtons.hidden = true })
|
|
94
|
+
map.on('app:fullscreenchange', function (e) { setInline(e.isFullscreen) })
|
|
95
|
+
|
|
96
|
+
map.on('interact:markerchange', function () {
|
|
97
|
+
continueBtn.disabled = false
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
continueBtn.addEventListener('click', function () {
|
|
101
|
+
// navigate to next step
|
|
102
|
+
})
|
|
103
|
+
</script>
|
|
104
|
+
{% endblock %}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{% extends "layouts/main.html" %}
|
|
2
|
+
|
|
3
|
+
{% block pageTitle %}
|
|
4
|
+
Add a search control – GOV.UK Prototype Kit
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block head %}
|
|
8
|
+
<link href="/public/stylesheets/application.css" rel="stylesheet" type="text/css">
|
|
9
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
10
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/plugins/search/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
11
|
+
{% endblock %}
|
|
12
|
+
|
|
13
|
+
{% block bodyStart %}
|
|
14
|
+
<script>document.body.classList.add('im-is-loading')</script>
|
|
15
|
+
{% endblock %}
|
|
16
|
+
|
|
17
|
+
{% block beforeContent %}
|
|
18
|
+
{{ govukBackLink({
|
|
19
|
+
text: "Back",
|
|
20
|
+
href: "javascript:window.history.back()"
|
|
21
|
+
}) }}
|
|
22
|
+
{% endblock %}
|
|
23
|
+
|
|
24
|
+
{% block content %}
|
|
25
|
+
<div class="govuk-grid-row">
|
|
26
|
+
<div class="govuk-grid-column-two-thirds">
|
|
27
|
+
|
|
28
|
+
<h1 class="govuk-heading-l">
|
|
29
|
+
Add a search control
|
|
30
|
+
</h1>
|
|
31
|
+
|
|
32
|
+
<div id="map"></div>
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
{% endblock %}
|
|
37
|
+
|
|
38
|
+
{% block pageScripts %}
|
|
39
|
+
<!-- Defra library scripts -->
|
|
40
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/dist/umd/index.js"></script>
|
|
41
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/providers/maplibre/dist/umd/index.js"></script>
|
|
42
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/plugins/search/dist/umd/index.js"></script>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
const SETTLEMENT_TYPES = new Set(['city', 'town', 'village', 'hamlet', 'suburb', 'quarter', 'neighbourhood', 'municipality', 'borough', 'district', 'county'])
|
|
46
|
+
|
|
47
|
+
const nominatimDataset = {
|
|
48
|
+
name: 'nominatim',
|
|
49
|
+
buildRequest: function (query) {
|
|
50
|
+
const params = new URLSearchParams({
|
|
51
|
+
q: query,
|
|
52
|
+
format: 'json',
|
|
53
|
+
limit: '8',
|
|
54
|
+
countrycodes: 'gb'
|
|
55
|
+
})
|
|
56
|
+
return new Request('https://nominatim.openstreetmap.org/search?' + params, {
|
|
57
|
+
headers: { 'Accept-Language': 'en' }
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
parseResults: function (json, query) {
|
|
61
|
+
if (!Array.isArray(json)) return []
|
|
62
|
+
const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
63
|
+
const results = json
|
|
64
|
+
.filter(function (item) { return SETTLEMENT_TYPES.has(item.addresstype) })
|
|
65
|
+
.map(function (item) {
|
|
66
|
+
const bb = item.boundingbox.map(Number)
|
|
67
|
+
return {
|
|
68
|
+
id: String(item.place_id),
|
|
69
|
+
text: item.display_name,
|
|
70
|
+
marked: item.display_name.replace(new RegExp('(' + escaped + ')', 'i'), '<mark>$1</mark>'),
|
|
71
|
+
point: [Number(item.lon), Number(item.lat)],
|
|
72
|
+
bounds: [bb[2], bb[0], bb[3], bb[1]]
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
return Array.from(new Map(results.map(function (r) { return [r.text, r] })).values())
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const searchPlugin = defra.searchPlugin({
|
|
80
|
+
customDatasets: [nominatimDataset],
|
|
81
|
+
width: '300px'
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
new defra.InteractiveMap('map', {
|
|
85
|
+
behaviour: 'inline',
|
|
86
|
+
mapProvider: defra.maplibreProvider(),
|
|
87
|
+
mapStyle: {
|
|
88
|
+
url: 'https://tiles.openfreemap.org/styles/liberty',
|
|
89
|
+
attribution: 'OpenFreeMap © OpenMapTiles Data from OpenStreetMap',
|
|
90
|
+
backgroundColor: '#f5f5f0'
|
|
91
|
+
},
|
|
92
|
+
center: [-1.6, 53.1],
|
|
93
|
+
zoom: 6,
|
|
94
|
+
containerHeight: '516px',
|
|
95
|
+
plugins: [searchPlugin]
|
|
96
|
+
})
|
|
97
|
+
</script>
|
|
98
|
+
{% endblock %}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{% extends "layouts/main.html" %}
|
|
2
|
+
|
|
3
|
+
{% block pageTitle %}
|
|
4
|
+
Select a feature – GOV.UK Prototype Kit
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block head %}
|
|
8
|
+
<link href="/public/stylesheets/application.css" rel="stylesheet" type="text/css">
|
|
9
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
10
|
+
{% endblock %}
|
|
11
|
+
|
|
12
|
+
{% block bodyStart %}
|
|
13
|
+
<script>document.body.classList.add('im-is-loading')</script>
|
|
14
|
+
{% endblock %}
|
|
15
|
+
|
|
16
|
+
{% block beforeContent %}
|
|
17
|
+
{{ govukBackLink({
|
|
18
|
+
text: "Back",
|
|
19
|
+
href: "javascript:window.history.back()"
|
|
20
|
+
}) }}
|
|
21
|
+
{% endblock %}
|
|
22
|
+
|
|
23
|
+
{% block content %}
|
|
24
|
+
<div class="govuk-grid-row">
|
|
25
|
+
<div class="govuk-grid-column-two-thirds">
|
|
26
|
+
|
|
27
|
+
<h1 class="govuk-heading-l">
|
|
28
|
+
Select a feature
|
|
29
|
+
</h1>
|
|
30
|
+
|
|
31
|
+
<div id="map"></div>
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
{% endblock %}
|
|
36
|
+
|
|
37
|
+
{% block pageScripts %}
|
|
38
|
+
<!-- Defra library scripts -->
|
|
39
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/dist/umd/index.js"></script>
|
|
40
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/providers/maplibre/dist/umd/index.js"></script>
|
|
41
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/plugins/interact/dist/umd/index.js"></script>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
const PANEL_ID = 'building-info'
|
|
45
|
+
|
|
46
|
+
const interactPlugin = defra.interactPlugin({
|
|
47
|
+
interactionModes: ['selectFeature'],
|
|
48
|
+
deselectOnClickOutside: true,
|
|
49
|
+
layers: [
|
|
50
|
+
{ layerId: 'buildings 3D', idProperty: 'uuid' }
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const map = new defra.InteractiveMap('map', {
|
|
55
|
+
behaviour: 'inline',
|
|
56
|
+
mapProvider: defra.maplibreProvider(),
|
|
57
|
+
mapStyle: {
|
|
58
|
+
url: 'https://labs.os.uk/tiles/styles/open-zoomstack-outdoor/style.json',
|
|
59
|
+
attribution: `Contains OS data © Crown copyright and database rights ${new Date().getFullYear()}`,
|
|
60
|
+
backgroundColor: '#f5f5f0'
|
|
61
|
+
},
|
|
62
|
+
center: [-1.5491, 53.8008],
|
|
63
|
+
zoom: 14.5,
|
|
64
|
+
maxZoom: 14.5,
|
|
65
|
+
containerHeight: '516px',
|
|
66
|
+
plugins: [interactPlugin]
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
map.on('map:ready', () => {
|
|
70
|
+
interactPlugin.enable()
|
|
71
|
+
|
|
72
|
+
map.addPanel(PANEL_ID, {
|
|
73
|
+
focus: false,
|
|
74
|
+
label: 'Selected building',
|
|
75
|
+
html: '<div id="building-info-content"></div>',
|
|
76
|
+
mobile: { slot: 'drawer', dismissible: true, open: false },
|
|
77
|
+
tablet: { slot: 'left-top', dismissible: true, width: '300px', open: false },
|
|
78
|
+
desktop: { slot: 'left-top', dismissible: true, width: '300px', open: false }
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
map.on('interact:selectionchange', ({ selectedFeatures }) => {
|
|
83
|
+
if (selectedFeatures.length > 0) {
|
|
84
|
+
let html = ''
|
|
85
|
+
for (const [k, v] of Object.entries(selectedFeatures[0].properties)) {
|
|
86
|
+
html += '<p class="govuk-body govuk-!-margin-bottom-1"><strong>' + k + ':</strong> ' + v + '</p>'
|
|
87
|
+
}
|
|
88
|
+
document.getElementById('building-info-content').innerHTML = html
|
|
89
|
+
map.showPanel(PANEL_ID)
|
|
90
|
+
} else {
|
|
91
|
+
map.hidePanel(PANEL_ID)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
map.on('app:panelclosed', ({ panelId }) => {
|
|
96
|
+
if (panelId === PANEL_ID) {
|
|
97
|
+
interactPlugin.clear()
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
</script>
|
|
101
|
+
{% endblock %}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{% extends "layouts/main.html" %}
|
|
2
|
+
|
|
3
|
+
{% block pageTitle %}
|
|
4
|
+
Change map style – GOV.UK Prototype Kit
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block head %}
|
|
8
|
+
<link href="/public/stylesheets/application.css" rel="stylesheet" type="text/css">
|
|
9
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
10
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/plugins/beta/map-styles/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
11
|
+
{% endblock %}
|
|
12
|
+
|
|
13
|
+
{% block bodyStart %}
|
|
14
|
+
<script>document.body.classList.add('im-is-loading')</script>
|
|
15
|
+
{% endblock %}
|
|
16
|
+
|
|
17
|
+
{% block beforeContent %}
|
|
18
|
+
{{ govukBackLink({
|
|
19
|
+
text: "Back",
|
|
20
|
+
href: "javascript:window.history.back()"
|
|
21
|
+
}) }}
|
|
22
|
+
{% endblock %}
|
|
23
|
+
|
|
24
|
+
{% block content %}
|
|
25
|
+
<div class="govuk-grid-row">
|
|
26
|
+
<div class="govuk-grid-column-two-thirds">
|
|
27
|
+
|
|
28
|
+
<h1 class="govuk-heading-l">
|
|
29
|
+
Change map style
|
|
30
|
+
</h1>
|
|
31
|
+
|
|
32
|
+
<div id="map"></div>
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
{% endblock %}
|
|
37
|
+
|
|
38
|
+
{% block pageScripts %}
|
|
39
|
+
<!-- Defra library scripts -->
|
|
40
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/dist/umd/index.js"></script>
|
|
41
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/providers/maplibre/dist/umd/index.js"></script>
|
|
42
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/plugins/beta/map-styles/dist/umd/index.js"></script>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
const attribution = 'OpenFreeMap © OpenMapTiles Data from OpenStreetMap'
|
|
46
|
+
|
|
47
|
+
const mapStyles = [
|
|
48
|
+
{
|
|
49
|
+
id: 'road',
|
|
50
|
+
label: 'Road',
|
|
51
|
+
url: 'https://tiles.openfreemap.org/styles/liberty',
|
|
52
|
+
thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/road-ofm-thumb.jpg',
|
|
53
|
+
attribution,
|
|
54
|
+
backgroundColor: '#f5f5f0'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'bright',
|
|
58
|
+
label: 'Bright',
|
|
59
|
+
url: 'https://tiles.openfreemap.org/styles/bright',
|
|
60
|
+
thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/bright-ofm-thumb.jpg',
|
|
61
|
+
attribution,
|
|
62
|
+
backgroundColor: '#f5f5f0'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'dark',
|
|
66
|
+
label: 'Dark',
|
|
67
|
+
url: 'https://tiles.openfreemap.org/styles/fiord',
|
|
68
|
+
thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/dark-ofm-thumb.jpg',
|
|
69
|
+
attribution,
|
|
70
|
+
mapColorScheme: 'dark',
|
|
71
|
+
appColorScheme: 'dark'
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
const mapStylesPlugin = defra.mapStylesPlugin({ mapStyles })
|
|
76
|
+
|
|
77
|
+
new defra.InteractiveMap('map', {
|
|
78
|
+
behaviour: 'inline',
|
|
79
|
+
mapProvider: defra.maplibreProvider(),
|
|
80
|
+
mapStyle: mapStyles[0],
|
|
81
|
+
center: [-0.1276, 51.5074],
|
|
82
|
+
zoom: 12,
|
|
83
|
+
containerHeight: '516px',
|
|
84
|
+
plugins: [mapStylesPlugin]
|
|
85
|
+
})
|
|
86
|
+
</script>
|
|
87
|
+
{% endblock %}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{% extends "layouts/main.html" %}
|
|
2
|
+
|
|
3
|
+
{% block pageTitle %}
|
|
4
|
+
Toggle marker label – GOV.UK Prototype Kit
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block head %}
|
|
8
|
+
<link href="/public/stylesheets/application.css" rel="stylesheet" type="text/css">
|
|
9
|
+
<link href="/plugin-assets/%40defra%2Finteractive-map/dist/css/index.css" rel="stylesheet" type="text/css">
|
|
10
|
+
{% endblock %}
|
|
11
|
+
|
|
12
|
+
{% block bodyStart %}
|
|
13
|
+
<script>document.body.classList.add('im-is-loading')</script>
|
|
14
|
+
{% endblock %}
|
|
15
|
+
|
|
16
|
+
{% block beforeContent %}
|
|
17
|
+
{{ govukBackLink({
|
|
18
|
+
text: "Back",
|
|
19
|
+
href: "javascript:window.history.back()"
|
|
20
|
+
}) }}
|
|
21
|
+
{% endblock %}
|
|
22
|
+
|
|
23
|
+
{% block content %}
|
|
24
|
+
<div class="govuk-grid-row">
|
|
25
|
+
<div class="govuk-grid-column-two-thirds">
|
|
26
|
+
|
|
27
|
+
<h1 class="govuk-heading-l">
|
|
28
|
+
Toggle marker label
|
|
29
|
+
</h1>
|
|
30
|
+
|
|
31
|
+
<div id="map"></div>
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
{% endblock %}
|
|
36
|
+
|
|
37
|
+
{% block pageScripts %}
|
|
38
|
+
<!-- Defra library scripts -->
|
|
39
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/dist/umd/index.js"></script>
|
|
40
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/providers/maplibre/dist/umd/index.js"></script>
|
|
41
|
+
<script src="/plugin-assets/%40defra%2Finteractive-map/plugins/interact/dist/umd/index.js"></script>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
const interactPlugin = defra.interactPlugin({
|
|
45
|
+
deselectOnClickOutside: true
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const map = new defra.InteractiveMap('map', {
|
|
49
|
+
behaviour: 'inline',
|
|
50
|
+
mapProvider: defra.maplibreProvider(),
|
|
51
|
+
mapStyle: {
|
|
52
|
+
url: 'https://tiles.openfreemap.org/styles/liberty',
|
|
53
|
+
attribution: 'OpenFreeMap © OpenMapTiles Data from OpenStreetMap',
|
|
54
|
+
backgroundColor: '#f5f5f0'
|
|
55
|
+
},
|
|
56
|
+
center: [-2.96, 54.43],
|
|
57
|
+
zoom: 15,
|
|
58
|
+
containerHeight: '516px',
|
|
59
|
+
plugins: [interactPlugin]
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
map.on('map:ready', () => {
|
|
63
|
+
map.addMarker('my-marker', [-2.96, 54.43], {
|
|
64
|
+
label: 'My location',
|
|
65
|
+
showLabel: false
|
|
66
|
+
})
|
|
67
|
+
interactPlugin.enable()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
map.on('interact:selectionchange', ({ selectedMarkers }) => {
|
|
71
|
+
map.updateMarker('my-marker', { showLabel: selectedMarkers.includes('my-marker') })
|
|
72
|
+
})
|
|
73
|
+
</script>
|
|
74
|
+
{% endblock %}
|