diff --git a/demo/js/draw.js b/demo/js/draw.js index 8f1143bd..f878b7e1 100755 --- a/demo/js/draw.js +++ b/demo/js/draw.js @@ -85,7 +85,7 @@ const datasetsPlugin = createDatasetsPlugin({ }) const interactiveMap = new InteractiveMap('map', { - behaviour: 'hybrid', + behaviour: 'mapOnly', mapProvider: maplibreProvider(), reverseGeocodeProvider: openNamesProvider({ url: process.env.OS_NEAREST_URL, @@ -102,7 +102,7 @@ const interactiveMap = new InteractiveMap('map', { autoColorScheme: true, // center: [-2.938769, 54.893806], bounds: [-2.989707, 54.864555, -2.878635, 54.937635], - containerHeight: '650px', + containerHeight: '600px', transformRequest: transformVtsRequest3857, enableZoomControls: true, readMapText: true, diff --git a/demo/js/mapStyles.js b/demo/js/mapStyles.js index 6b07f31b..4c64a15b 100755 --- a/demo/js/mapStyles.js +++ b/demo/js/mapStyles.js @@ -65,7 +65,7 @@ const vtsMapStyles3857 = [{ thumbnail: DARK_THUMBNAIL, logo: OS_LOGO_WHITE, logoAltText: OS_LOGO_ALT, - attribution: 'Test' + attribution: OS_ATTRIBUTION }, { id: BW_ID, label: BW_LABEL, @@ -73,7 +73,7 @@ const vtsMapStyles3857 = [{ thumbnail: BW_THUMBNAIL, logo: OS_LOGO_BLACK, logoAltText: OS_LOGO_ALT, - attribution: 'Test' + attribution: OS_ATTRIBUTION }, { id: 'aerial', label: 'Aerial', diff --git a/plugins/beta/draw-ml/src/events.js b/plugins/beta/draw-ml/src/events.js index be0e58fb..c1a2a3b5 100755 --- a/plugins/beta/draw-ml/src/events.js +++ b/plugins/beta/draw-ml/src/events.js @@ -1,4 +1,4 @@ -import { clearSnapState, getSnapInstance } from './utils/snapHelpers.js' +import { clearSnapState, clearSnapIndicator, getSnapInstance } from './utils/snapHelpers.js' export function attachEvents ({ pluginState, mapProvider, buttonConfig, eventBus }) { const { drawDone, drawAddPoint, drawUndo, drawDeletePoint, drawSnap, drawCancel } = buttonConfig @@ -101,6 +101,15 @@ export function attachEvents ({ pluginState, mapProvider, buttonConfig, eventBus } } + // --- Ensure snap indicator is hidden whenever not in a drawing mode + const DRAWING_MODES = ['draw_polygon', 'draw_line'] + const handleModeChange = (e) => { + if (!DRAWING_MODES.includes(e.mode)) { + const snap = getSnapInstance(map) + clearSnapIndicator(snap, map) + } + } + // --- Map style update const handleStyleData = () => { const layers = map.getStyle().layers || [] @@ -113,6 +122,7 @@ export function attachEvents ({ pluginState, mapProvider, buttonConfig, eventBus // --- Draw completion handlers (create / edit) const handleDrawCompletion = (eventName) => (e) => { const newFeature = e.features[0] + disableSnap() resetDrawModeAndFeature() setTimeout(() => draw.changeMode('disabled'), 0) eventBus.emit(eventName, newFeature) @@ -148,6 +158,7 @@ export function attachEvents ({ pluginState, mapProvider, buttonConfig, eventBus map.on('styledata', handleStyleData) map.on('draw.cancel', handleCancel) map.on('draw.create', onCreate) + map.on('draw.modechange', handleModeChange) map.on('draw.editfinish', onEditFinish) map.on('draw.update', handleUpdate) map.on('draw.vertexselection', onVertexSelection) @@ -166,6 +177,7 @@ export function attachEvents ({ pluginState, mapProvider, buttonConfig, eventBus map.off('draw.create', onCreate) map.off('draw.editfinish', onEditFinish) map.off('draw.update', handleUpdate) + map.off('draw.modechange', handleModeChange) map.off('draw.vertexselection', onVertexSelection) map.off('draw.vertexchange', onVertexChange) map.off('draw.undochange', onUndoChange)