Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add draw control component #767

Closed
wants to merge 2 commits into from
Closed

add draw control component #767

wants to merge 2 commits into from

Conversation

xintongxia
Copy link

@xintongxia xintongxia commented Mar 26, 2019

for #734

Xintong Xia added 2 commits March 26, 2019 14:28
[WIP] add draw control

Switch to eventManager

add style callback

add styling

add delete operation

add testing geometries

rebase
@ibgreen
Copy link
Contributor

ibgreen commented Mar 27, 2019

@georgios-uber @supersonicclay FYI, lightweight "alternative" to nebula.gl being added to react-map-gl, would be nice to see if any alignment of API / semantics could be done such that this could be thought of as a "nebula light".

@supersonicclay
Copy link

You may look at naming the prop selectedIds rather than selectedId and have it an array rather than single value. It will prevent you from having to make a breaking change in the future when you want to support multi-select. You could even throw a not supported error if a caller provides more than one value in that array.

Another thing that was super useful in nebula was to support custom modes that can be provided by a consuming application. Nebula calls them ModeHandlers. It can look something like this:

import {DrawPolygonHandler, ModeHandler, EditableGeoJsonLayer} from 'nebula.gl';

class MyAwesomeModeHandler extends ModeHandler {
  // override onClick, onDrag, etc
}

// ...

new EditableGeoJsonLayer({
  modeHandlers: {
    'drawPolygon': DrawPolygonHandler, // DrawPolygonHandler is a built-in mode supported by nebula
    'myAwesomeMode': MyAwesomeModeHandler // a custom mode that is either specific to their app or one that we didn't think of or haven't built yet in nebula
  },
  mode: 'myAwesomeMode'
});

@supersonicclay
Copy link

It isn't documented really well, but here's the base ModeHandler class:
https://github.com/uber/nebula.gl/blob/master/modules/layers/src/mode-handlers/mode-handler.js

And here are the built-in modes that nebula provides:
https://github.com/uber/nebula.gl/blob/master/docs/api-reference/mode-handlers/overview.md

mode={mode}
features={features}
selectedId={selectedId}
onSelect={this._onSelect}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might rename this to onSelectionChanged so it can support select and deselect and, in the future, multi-select.

@georgios-uber georgios-uber self-requested a review March 27, 2019 17:24
@georgios-uber
Copy link

georgios-uber commented Mar 27, 2019

@xintongxia @supersonicclay Do you think this can import and use nebula's mode-handlers?

@Pessimistress
Copy link
Collaborator

This component has been moved into https://github.com/uber/nebula.gl/tree/master/modules/react-map-gl-draw

@Pessimistress Pessimistress deleted the xx/draw-control branch May 9, 2019 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants