Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion demo/js/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const interactPlugin = createInteractPlugin({
layerId: 'stroke-inactive.cold',
idProperty: 'id'
}],
debug: true,
// debug: true,
interactionModes: ['selectMarker', 'selectFeature'], // e.g. ['selectMarker'], ['selectFeature'], ['placeMarker'], or combinations
multiSelect: true,
contiguous: true,
Expand Down Expand Up @@ -243,6 +243,10 @@ interactiveMap.on('draw:started', function (e) {
interactPlugin.disable()
})

interactiveMap.on('draw:editstart', function (e) {
console.log('draw:editstart', e)
})

interactiveMap.on('draw:created', function (e) {
console.log('draw:created', e)
interactiveMap.toggleButtonState('geometryActions', 'hidden', false)
Expand Down
13 changes: 9 additions & 4 deletions plugins/beta/draw-ml/src/api/editFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ import { getSnapInstance } from '../utils/snapHelpers.js'
* @param {string} featureId - ID of the feature to edit
* @param {object} options - Options including snapLayers
*/
export const editFeature = ({ appState, appConfig, mapState, pluginConfig, pluginState, mapProvider }, featureId, options = {}) => {
export const editFeature = ({ appState, appConfig, mapState, pluginConfig, pluginState, mapProvider, services }, featureId, options = {}) => {
const { dispatch } = pluginState
const { draw, map } = mapProvider
const { eventBus } = services

if (!draw) {
return
return false
}

// Guard: feature must exist in draw before doing anything
if (!draw.get(featureId)) {
return
const existingFeature = draw.get(featureId)
if (!existingFeature) {
return false
}

const editModeMap = { LineString: 'edit_line', Polygon: 'edit_polygon' }
eventBus.emit('draw:editstart', { mode: editModeMap[existingFeature.geometry.type] })

// Determin snapLayers from pluginConfig or runtime config
let snapLayers = null
if (options.snapLayers === undefined) {
Expand Down
Loading