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
RFC: DrawControl #734
Comments
Nice! I think this could work, looking forward to playing with this. Few questions since Pessimistress asked to provice feedback:
|
This proposal is great! Thanks for putting this together - and especially for including a wonderful example! A few initial thoughts/questions:
Thanks again for putting this together! Hope I didn't give too much feedback there. Looking forward to hearing your thoughts! |
My understanding of the plan is to provide both JS styling and classname-based styling. The JavaScript
Corrected.
Yes. |
This is fantastic! Thanks for putting this together. In terms of functionality I think it looks pretty comprehensive, though I'm also wondering about the ability to drag vertices once they're created. I also wanted to double check my understanding of how geometry drawn on the proposed overlay would relate to other geometry being rendered by the map. In our use case, we want users to draw on the map and then persist their drawn geometry such that it can be rendered by the map once the user leaves draw mode. So, if I'm understanding correctly, a full draw workflow under the current proposal might look like this:
Which I think would be a reasonable workflow-- I just wanted to make sure I understand where the responsibilities of the draw overlay end and the underlying map begin. Thanks again for your work on this, and I'm looking forward to playing around with the overlay! |
I think it is not possible to support drawing and dragging at the same time, for example while drawing a polygon, when the user interacts with a vertex that is already drawn,
I am thinking of changing
We are not going to include this for the initial release. But I agree with you, this is an interesting feature, we probably will leverage it in future. |
@goldpbear Your workflow looks about right to me. The only thing I would like to bring attention to is that the proposed DrawControl renders an SVGOverlay, so there are these limitations:
|
We do not include multi-polygons or polygons with holes for the initial release. But I will investigate how to implement these features.
I am thinking to change the
Thanks for pointing out. I am going to remove |
LGTM, couple questions.
|
Agreed, will also support drawing rectangle in this
I am thinking,
Yes, I think you are right. We don't really need differentiate |
It might still be useful to differentiate between polygon and path in order to close the polygon automatically when the user is done editing. It seems like it might be difficult for the user to add a vertex at the exact point to close the path, but maybe this is not an issue. |
Adding some thoughts on the relation to nebula.gl and the fact that we are creating two features with overlapping functionality: @georgios-uber @supersonicclay Could make sense for the nebula team to keep an eye on this RFC. It would for instance be nice if the API/functionality remains a reasonably clean subset of nebula.gl, facilitating a seamless upgrade path to nebula.gl for users who start with this feature once more advanced features become needed. @xintongxia I think it would be neat if the docs of this react-map-gl feature linked to nebula.gl and gave some recommendations when to use which version: nebula.gl has already done the reciprocal doc update, I paste the current overview text in nebula.gl. Overviewnebula.gl provides editable and interactive map overlay layers, built using the power of deck.gl. Design Goalsnebula.gl aspires to be an ultra-performant, fully 3D-enabled GeoJSON editing system primarily focused on geospatial editing use cases.
Why nebula.gl?You should strongly consider nebula.gl:
You may want to look at alternatives if:
If nebula.gl is more than what you need (e.g. in terms of bundle size), and you may want to look at other solutions, e.g. the simple polygon editor overlay being developed in react-map-gl. That said, if you are already using |
This was the first impression I got from playing with the mapbox-gl-draw demo. Having the option to skip redundant clicking would be nice. |
Is there any chance we can add a free-hand drawing mode? The workflow could be
|
This module is now a submodule of nebula.gl. The nebula team have an extensible draw mode system and are implementing many draw modes that users can choose from. The idea is that those editing modes will be made compatible not only with nebula's main module (the editable deck.gl layers) but also with this little React component. For quickest response, recommend asking this and other related questions in the nebula.gl repo. |
We have a feature request for free-hand drawing in nebula.gl. It's here: uber/nebula.gl#172 |
@xintongxia can you add this rfc to nebula repo and .md file? |
RFC: DrawControl
Background
react-map-gl currently does not support drawing functions. However, we have got a couple of users interested in this capability. Also it is one of P0 features on Kepler.gl 2019 roadmap.
Although Mapbox/mapbox-gl-draw provides quite nice drawing and editing features, because of its manipulating internal states, it cannot work well with React / Redux framework and therefore cannot be integrated with
react-map-gl
.vis.gl offers another geo editing library Nebula.gl, but it is an overkill while adding heavy dependencies such as deck.gl.
Proposal
react-map-gl
can provide aDrawControl
, starts from simple functions like the following.Options
mode
(String, Optional) -react-map-gl
is stateless, user has complete control of themode
.DrawControl.READ_ONLY
- Not interactive. This is the default mode.DrawControl.SELECT_FEATURE
- Lets you select, delete, and drag features.DrawControl.SELECT_VERTEX
- Lets you select, delete, and drag vertices; and drag features.DrawControl.DRAW_PATH
- Lets you draw a LineString feature.DrawControl.DRAW_POLYGON
- Lets you draw a Polygon feature.DrawControl.DRAW_POINT
- Lets you draw a Point feature.styles
(Object, Optional) - A map of style objects passed to DOM elements. The following keys are supported.point
- SVG circle element.path
- SVG path element.polygon
- SVG path element.vertex
- SVG circle elementselectedVertex
selectedPoint
selectedPath
selectedPolygon
clickRadius
(Number, Optional) - Radius to detect features around a clicked point. Default is0
.features
(Array, Optional) - A list of GeoJSON Point, LineString, or Polygon features.selectedId
(String, Optional) - id of the selected feature.DrawControl
assigns a unique id to each feature which is stored infeature.properties.id
.onSelect
(Function, Required) - callback when a feature is selected. Receives one argumentselectedId
.onUpdate
(Function, Required) - callback when anything is updated. Receives one argumentfeatures
that is the updated list of GeoJSON features.onAdd
(Function, Optional) - callback when a new feature is finished drawing. Receives one argumentfeatureId
.onDelete
(Function, Optional) - callback when a feature is being deleted. Receives one argumentfeatureId
.Code Example
Compare with
mapbox-gl-draw
DrawControl
is a stateless component. To manipulate the features, simply change thefeatures
prop. This is different from calling the class methods ofMapboxDraw
.DrawControl
does not contain UI for mode selection, giving user application the flexibility to control their user experience.MapboxDraw
that are not planned for the initial release ofDrawControl
: keyboard navigation, box select.The text was updated successfully, but these errors were encountered: