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

RFC: react-map-gl-draw #229

Merged
merged 1 commit into from Jun 19, 2019
Merged

RFC: react-map-gl-draw #229

merged 1 commit into from Jun 19, 2019

Conversation

xintongxia
Copy link
Collaborator

@xintongxia xintongxia commented May 21, 2019

Port RFC from react-map-gl and update the API.

Below is a demo using react-map-gl-draw.

demo

@coveralls
Copy link

coveralls commented May 21, 2019

Pull Request Test Coverage Report for Build 1161

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 34.004%

Totals Coverage Status
Change from base Build 1152: 0.0%
Covered Lines: 936
Relevant Lines: 2269

💛 - Coveralls

- `EditorModes.DRAW_POINT` - Lets you draw a Point feature.
- `EditorModes.DRAW_RECTANGLE` - Lets you draw a Rectangle feature.

- `getFeatureStyle` (Function, Optional) : Object - A function to style features, function parameters are

Choose a reason for hiding this comment

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

isn't getFeatureStyle should be for path element, and getVertexStyle should be for circle and rect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the APIs. getVertexStyle is kind of exposing the implementation details. So decided to use getEditHandleStyle, which will be applied to the feature being edited.

- `EditorModes.DRAW_POINT` - Lets you draw a Point feature.
- `EditorModes.DRAW_RECTANGLE` - Lets you draw a Rectangle feature.

- `getFeatureStyle` (Function, Optional) : Object - A function to style features, function parameters are

Choose a reason for hiding this comment

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

Have we decided what style properties we will support here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

react-map-gl-draw is using svg circle, rect and path to draw features, so any styles which could be applied to these svg elements will be supported.

Choose a reason for hiding this comment

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

Ohhh - I had it in my head that this was drawing to the gl context. Does this then create an <svg> element and overlay it on top of the canvas where Deck and/or Mapbox are drawing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. All the drawing will be rendered in a svg overlay on top of react-map-gl base map

- `EditorModes.DRAW_RECTANGLE` - Lets you draw a Rectangle feature.

- `getFeatureStyle` (Function, Optional) : Object - A function to style features, function parameters are
- `feature`: feature to style

Choose a reason for hiding this comment

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

Are features represented by geojson? Or SVG elements?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

features are following GeoJson format, each data point has longitude, and latitude value.

features are rendered using svg elements. react-map-gl-draw will use the viewport provided by MapcontextProvider to project the lng, lat to screen coordinates and render in svg.

- `mode` (String, Optional) - `react-map-gl` is stateless, user has complete control of the `mode`.
- `EditorModes.READ_ONLY` - Not interactive. This is the default mode.
- `EditorModes.SELECT_FEATURE` - Lets you select, delete, and drag features.
- `EditorModes.EDIT_VERTEX` - Lets you select, delete, and drag vertices; and drag features.

Choose a reason for hiding this comment

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

I'd prefer selectable and editable be independent flags from the modes. This would support the scenario where the app allows the user to draw new features and edit existing features at the same time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What would it take to get these EditorModes to just be nebula.gl EditModes?

Copy link
Collaborator Author

@xintongxia xintongxia Jun 5, 2019

Choose a reason for hiding this comment

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

This refactor is the first step, which helps me to understand what kinds of behaviors are expected under different modes. Then the next step is to extract handlers for different modes by extending edit-modes module.

dev-docs/RFCs/v1.0/react-map-gl-draw.md Outdated Show resolved Hide resolved
dev-docs/RFCs/v1.0/react-map-gl-draw.md Outdated Show resolved Hide resolved
dev-docs/RFCs/v1.0/react-map-gl-draw.md Outdated Show resolved Hide resolved
dev-docs/RFCs/v1.0/react-map-gl-draw.md Outdated Show resolved Hide resolved
Update doc based on suggestions

Fix example code and address comments

fix inconsistent naming

Update with more explanations and resolve comments

udpate API

resolve comments
@xintongxia xintongxia merged commit 1817b61 into master Jun 19, 2019
@xintongxia xintongxia deleted the xx/react-map-gl-draw-rfc branch June 19, 2019 15:25
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

8 participants