uber / nebula.gl

A suite of 3D-enabled data editing overlays, suitable for deck.gl
https://nebula.gl/
Other
691 stars 165 forks source link

Select drawn shape programmatically #406

Open intelcoder opened 4 years ago

intelcoder commented 4 years ago

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

xintongxia commented 4 years ago

@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

intelcoder commented 4 years ago

@xintongxia I am using react-map-gl-draw. The link you attached does not work and shows BrowserFS is not defined on dev tool

xintongxia commented 4 years ago

@intelcoder the link works now, codesanbox had some issues a moment ago.

intelcoder commented 4 years 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.

xintongxia commented 4 years ago

thanks for reporting. I'll look into it today.

petejank commented 4 years ago

I encountered same issue today.

How to reproduce:

  1. Render Editor with mode property set to new EditingMode() and prepopulated features property
  2. After initial render, update the selectedFeatureIndex to any valid integer within the range of your features
  3. Check console for the error

Noticed the error doesn't occur when I drag the map a bit and then update selectedFeatureIndex

eliaoucohen72 commented 2 years ago

Hi, Is there a fix for the bug?