@defra/interactive-map 0.0.54-alpha → 0.0.55-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/assets/templates/add-polygons.njk +1 -1
- package/assets/templates/add-symbols.njk +4 -4
- package/assets/templates/draw-tools.njk +7 -7
- package/assets/templates/marker-panel.njk +5 -5
- package/assets/templates/place-marker.njk +8 -8
- package/assets/templates/search-control.njk +1 -1
- package/assets/templates/select-feature.njk +7 -7
- package/assets/templates/style-switcher.njk +4 -4
- package/assets/templates/toggle-marker-label.njk +3 -3
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/im-core.js.LICENSE.txt +0 -30
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.LICENSE.txt +0 -20
- package/docs/api.md +3 -13
- package/docs/building-a-plugin.md +2 -2
- package/docs/examples/add-marker-with-panel.mdx +46 -44
- package/docs/examples/add-polygons.mdx +100 -98
- package/docs/examples/add-symbols.mdx +75 -73
- package/docs/examples/basic-map.mdx +16 -14
- package/docs/examples/button-map.mdx +16 -14
- package/docs/examples/draw-tools.mdx +119 -117
- package/docs/examples/place-marker.mdx +51 -49
- package/docs/examples/search-control.mdx +22 -20
- package/docs/examples/select-feature.mdx +107 -105
- package/docs/examples/style-switcher.mdx +47 -45
- package/docs/examples/toggle-marker-label.mdx +30 -28
- package/docs/getting-started.md +26 -24
- package/docs/plugins/draw.md +10 -10
- package/docs/plugins/interact.md +9 -9
- package/docs/plugins/plugin-descriptor.md +1 -1
- package/docs/plugins/search.md +3 -3
- package/docusaurus.config.cjs +23 -0
- package/package.json +3 -7
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/dist/esm/index.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +1 -1
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/esm/index.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/index.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/esm/index.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/index.js +1 -1
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/esm/index.js +1 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/umd/index.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/layerAdapter.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/adapters/maplibre/styles.js +3 -2
- package/plugins/draw/src/adapters/maplibre/styles.test.js +3 -3
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.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/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/menu/dist/esm/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/umd/index.js +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/dist/esm/index.js +1 -1
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +1 -1
- package/providers/beta/open-names/dist/esm/index.js +1 -1
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/beta/open-names/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/esm/index.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/src/index.js +27 -4
- package/providers/beta/openlayers/src/index.test.js +47 -0
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +3 -3
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-worker.js +2 -0
- package/providers/maplibre/dist/umd/im-maplibre-worker.js.LICENSE.txt +4 -0
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +41 -12
- package/providers/maplibre/src/index.test.js +43 -12
- package/providers/maplibre/src/utils/detectModuleWorker.js +25 -0
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +40 -0
- package/providers/maplibre/src/utils/spatial.js +22 -12
- package/providers/maplibre/src/utils/spatial.test.js +6 -6
- package/providers/maplibre/src/utils/workerUrl.js +15 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -0
- package/rollup.esm.mjs +38 -1
- package/src/InteractiveMap/InteractiveMap.js +2 -1
- package/src/InteractiveMap/InteractiveMap.test.js +9 -2
- package/src/InteractiveMap/domStateManager.js +21 -1
- package/src/InteractiveMap/domStateManager.test.js +48 -1
- package/src/InteractiveMap/polyfills.js +4 -3
- package/src/InteractiveMap/polyfills.test.js +12 -0
- package/src/types.js +3 -5
- package/webpack.dev.mjs +2 -0
- package/webpack.umd.mjs +28 -7
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
mapProvider: defra.maplibreProvider(),
|
|
136
136
|
mapStyle: {
|
|
137
137
|
url: 'https://labs.os.uk/tiles/styles/open-zoomstack-outdoor/style.json',
|
|
138
|
-
attribution:
|
|
138
|
+
attribution: 'Contains OS data © Crown copyright and database rights ' + new Date().getFullYear(),
|
|
139
139
|
backgroundColor: '#f5f5f0'
|
|
140
140
|
},
|
|
141
141
|
center: [-2.464, 54.558],
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
filter: ['in', ['get', 'category'], 'prehistoric'],
|
|
80
80
|
style: {
|
|
81
81
|
symbol: 'square',
|
|
82
|
-
symbolGraphic,
|
|
82
|
+
symbolGraphic: symbolGraphic,
|
|
83
83
|
symbolBackgroundColor: '#00897B'
|
|
84
84
|
}
|
|
85
85
|
}, {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
filter: ['in', ['get', 'category'], 'roman'],
|
|
89
89
|
style: {
|
|
90
90
|
symbol: 'square',
|
|
91
|
-
symbolGraphic,
|
|
91
|
+
symbolGraphic: symbolGraphic,
|
|
92
92
|
symbolBackgroundColor: '#ca3535'
|
|
93
93
|
}
|
|
94
94
|
}, {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
filter: ['in', ['get', 'category'], 'medieval'],
|
|
98
98
|
style: {
|
|
99
99
|
symbol: 'square',
|
|
100
|
-
symbolGraphic,
|
|
100
|
+
symbolGraphic: symbolGraphic,
|
|
101
101
|
symbolBackgroundColor: '#1565C0'
|
|
102
102
|
}
|
|
103
103
|
}]
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
mapProvider: defra.maplibreProvider(),
|
|
112
112
|
mapStyle: {
|
|
113
113
|
url: 'https://labs.os.uk/tiles/styles/open-zoomstack-outdoor/style.json',
|
|
114
|
-
attribution:
|
|
114
|
+
attribution: 'Contains OS data © Crown copyright and database rights ' + new Date().getFullYear(),
|
|
115
115
|
backgroundColor: '#f5f5f0'
|
|
116
116
|
},
|
|
117
117
|
center: [-2.4608, 54.5574],
|
|
@@ -146,13 +146,13 @@
|
|
|
146
146
|
interactPlugin.enable()
|
|
147
147
|
})
|
|
148
148
|
|
|
149
|
-
interactiveMap.on('interact:selectionchange', function (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
selectedFeatureIds =
|
|
149
|
+
interactiveMap.on('interact:selectionchange', function (event) {
|
|
150
|
+
const singleFeature = event.selectedFeatures.length === 1
|
|
151
|
+
const anyFeature = event.selectedFeatures.length > 0
|
|
152
|
+
const isDrawFeature = singleFeature && DRAW_LAYERS.includes(event.selectedFeatures[0].layerId)
|
|
153
|
+
const isPolygon = singleFeature && event.selectedFeatures[0].geometryType === 'Polygon'
|
|
154
|
+
const allDrawFeatures = anyFeature && event.selectedFeatures.every(function (feature) { return DRAW_LAYERS.includes(feature.layerId) })
|
|
155
|
+
selectedFeatureIds = event.selectedFeatures.map(function (feature) { return feature.featureId })
|
|
156
156
|
interactiveMap.toggleButtonState('drawPolygon', 'disabled', singleFeature)
|
|
157
157
|
interactiveMap.toggleButtonState('drawLine', 'disabled', singleFeature)
|
|
158
158
|
interactiveMap.toggleButtonState('editFeature', 'disabled', !isDrawFeature)
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
plugins: [interactPlugin]
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
map.on('map:ready', ()
|
|
62
|
+
map.on('map:ready', function () {
|
|
63
63
|
map.addMarker('my-marker', [-2.968, 54.425])
|
|
64
64
|
interactPlugin.enable()
|
|
65
65
|
interactPlugin.selectMarker('my-marker')
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
})
|
|
75
75
|
})
|
|
76
76
|
|
|
77
|
-
map.on('interact:selectionchange', (
|
|
78
|
-
if (selectedMarkers.length > 0) {
|
|
77
|
+
map.on('interact:selectionchange', function (event) {
|
|
78
|
+
if (event.selectedMarkers.length > 0) {
|
|
79
79
|
map.showPanel('marker-info')
|
|
80
80
|
} else {
|
|
81
81
|
map.hidePanel('marker-info')
|
|
82
82
|
}
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
map.on('app:panelclosed', (
|
|
86
|
-
if (panelId === 'marker-info') {
|
|
85
|
+
map.on('app:panelclosed', function (event) {
|
|
86
|
+
if (event.panelId === 'marker-info') {
|
|
87
87
|
interactPlugin.unselectMarker('my-marker')
|
|
88
88
|
}
|
|
89
89
|
})
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
<script src="/plugin-assets/%40defra%2Finteractive-map/plugins/interact/dist/umd/index.js"></script>
|
|
46
46
|
|
|
47
47
|
<script>
|
|
48
|
-
|
|
48
|
+
const interactPlugin = defra.interactPlugin({
|
|
49
49
|
interactionModes: ['placeMarker']
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const map = new defra.InteractiveMap('map', {
|
|
53
53
|
behaviour: 'hybrid',
|
|
54
54
|
mapProvider: defra.maplibreProvider(),
|
|
55
55
|
mapStyle: {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
backLabel: 'Back',
|
|
66
66
|
continueLabel: 'Continue',
|
|
67
67
|
continueEnabledWhen: function (context) {
|
|
68
|
-
return context.mapState.markers.items.some(function (
|
|
68
|
+
return context.mapState.markers.items.some(function (item) { return item.id === 'location' })
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
})
|
|
@@ -75,23 +75,23 @@
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
map.on('app:continue', function (context) {
|
|
78
|
-
|
|
78
|
+
const marker = context.mapState.markers.items.find(function (item) { return item.id === 'location' })
|
|
79
79
|
// navigate to next step with marker.coords
|
|
80
80
|
if (marker) {
|
|
81
81
|
console.log('Continuing with marker at:', marker.coords)
|
|
82
82
|
}
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const continueBtn = document.getElementById('continue-btn')
|
|
86
|
+
const externalButtons = document.getElementById('external-buttons')
|
|
87
87
|
|
|
88
88
|
function setInline(isFullscreen) {
|
|
89
89
|
externalButtons.hidden = isFullscreen
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
map.on('app:opened', function (
|
|
92
|
+
map.on('app:opened', function (event) { setInline(event.isFullscreen) })
|
|
93
93
|
map.on('app:closed', function () { externalButtons.hidden = true })
|
|
94
|
-
map.on('app:fullscreenchange', function (
|
|
94
|
+
map.on('app:fullscreenchange', function (event) { setInline(event.isFullscreen) })
|
|
95
95
|
|
|
96
96
|
map.on('interact:markerchange', function () {
|
|
97
97
|
continueBtn.disabled = false
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
plugins: [datasetsPlugin, interactPlugin]
|
|
126
126
|
})
|
|
127
127
|
|
|
128
|
-
map.on('map:ready', ()
|
|
128
|
+
map.on('map:ready', function () {
|
|
129
129
|
interactPlugin.enable()
|
|
130
130
|
|
|
131
131
|
map.addPanel(PANEL_ID, {
|
|
@@ -138,19 +138,19 @@
|
|
|
138
138
|
})
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
-
map.on('interact:selectionchange', (
|
|
142
|
-
if (selectedFeatures.length > 0) {
|
|
143
|
-
const
|
|
141
|
+
map.on('interact:selectionchange', function (event) {
|
|
142
|
+
if (event.selectedFeatures.length > 0) {
|
|
143
|
+
const name = event.selectedFeatures[0].properties.name
|
|
144
144
|
document.getElementById('parcel-info-content').innerHTML =
|
|
145
|
-
|
|
145
|
+
'<p class="govuk-body govuk-!-margin-bottom-1">' + name + '</p>'
|
|
146
146
|
map.showPanel(PANEL_ID)
|
|
147
147
|
} else {
|
|
148
148
|
map.hidePanel(PANEL_ID)
|
|
149
149
|
}
|
|
150
150
|
})
|
|
151
151
|
|
|
152
|
-
map.on('app:panelclosed', (
|
|
153
|
-
if (panelId === PANEL_ID) {
|
|
152
|
+
map.on('app:panelclosed', function (event) {
|
|
153
|
+
if (event.panelId === PANEL_ID) {
|
|
154
154
|
interactPlugin.clear()
|
|
155
155
|
}
|
|
156
156
|
})
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
label: 'Road',
|
|
51
51
|
url: 'https://tiles.openfreemap.org/styles/liberty',
|
|
52
52
|
thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/road-ofm-thumb.jpg',
|
|
53
|
-
attribution,
|
|
53
|
+
attribution: attribution,
|
|
54
54
|
backgroundColor: '#f5f5f0'
|
|
55
55
|
},
|
|
56
56
|
{
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
label: 'Bright',
|
|
59
59
|
url: 'https://tiles.openfreemap.org/styles/bright',
|
|
60
60
|
thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/bright-ofm-thumb.jpg',
|
|
61
|
-
attribution,
|
|
61
|
+
attribution: attribution,
|
|
62
62
|
backgroundColor: '#f5f5f0'
|
|
63
63
|
},
|
|
64
64
|
{
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
label: 'Dark',
|
|
67
67
|
url: 'https://tiles.openfreemap.org/styles/fiord',
|
|
68
68
|
thumbnail: '/plugin-assets/%40defra%2Finteractive-map/assets/images/dark-ofm-thumb.jpg',
|
|
69
|
-
attribution,
|
|
69
|
+
attribution: attribution,
|
|
70
70
|
mapColorScheme: 'dark',
|
|
71
71
|
appColorScheme: 'dark'
|
|
72
72
|
}
|
|
73
73
|
]
|
|
74
74
|
|
|
75
|
-
const mapStylesPlugin = defra.mapStylesPlugin({ mapStyles })
|
|
75
|
+
const mapStylesPlugin = defra.mapStylesPlugin({ mapStyles: mapStyles })
|
|
76
76
|
|
|
77
77
|
new defra.InteractiveMap('map', {
|
|
78
78
|
behaviour: 'inline',
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
plugins: [interactPlugin]
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
map.on('map:ready', ()
|
|
62
|
+
map.on('map:ready', function () {
|
|
63
63
|
map.addMarker('my-marker', [-2.96, 54.43], {
|
|
64
64
|
label: 'My location',
|
|
65
65
|
showLabel: false
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
interactPlugin.enable()
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
map.on('interact:selectionchange', (
|
|
71
|
-
map.updateMarker('my-marker', { showLabel: selectedMarkers.includes('my-marker') })
|
|
70
|
+
map.on('interact:selectionchange', function (event) {
|
|
71
|
+
map.updateMarker('my-marker', { showLabel: event.selectedMarkers.includes('my-marker') })
|
|
72
72
|
})
|
|
73
73
|
</script>
|
|
74
74
|
{% endblock %}
|