Select drawn shape programmatically
Describe the bug
I am not 100% sure if this is intentional. When I was using 0.16 version. I was able to select drawn shape programmatically using _onSelect function and pass mode to editor
// this code trigger onSelectFeature
editor.current._onSelect({
selectedFeatureIndex: 0,
})
After updating mode, editor mode changed to edit mode and select first drawn shape which shows handler as well.
However, I cannot seem to select feature anymore.
The reason why I need to do this is that drawn shape prevent user from panning.
Actual Result
Cannot select drawn shape programmatically
Expected Result
Select drawn shape programmatically by passing selectedFeatureIndex
To Do List
- [ ] Add label and assign to milestone
- [ ] Coding
- [ ] Test
@intelcoder which module you are using? If you are using react-map-gl-draw, check the doc for most up-to-date API.
Here is a sandbox example
@xintongxia I am using react-map-gl-draw. The link you attached does not work and shows BrowserFS is not defined on dev tool
@intelcoder the link works now, codesanbox had some issues a moment ago.
Sorry, I miss the part that I can now pass selectedFeatureIndex to the editor. However, it is crashing on this case.
User provide a feature and selectedFeatureIndex Initially, modeHandler is null
Now. User click edit button which sets selectFeatureIndex = 0, and modeHandler to new EditingMode()
Then, it throws
Cannot read property 'isDragging' of null
Here is sendbox example
If I do not pass initial features and draw, everything works fine.
thanks for reporting. I'll look into it today.
I encountered same issue today.
How to reproduce:
- Render
Editorwithmodeproperty set tonew EditingMode()and prepopulatedfeaturesproperty - After initial render, update the
selectedFeatureIndexto any valid integer within the range of yourfeatures - Check console for the error
Noticed the error doesn't occur when I drag the map a bit and then update selectedFeatureIndex
Hi, Is there a fix for the bug?