Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Adding draw on map for search example - #983

Merged
langsmith merged 4 commits into
masterfrom
ls-adding-drag-to-draw-example
May 31, 2019
Merged

langsmith merged 4 commits into
masterfrom
ls-adding-drag-to-draw-example

Conversation

@langsmith

@langsmith langsmith commented Mar 4, 2019 •

Copy link
Copy Markdown
Contributor

This pr adds an example of using View.OnTouchListener to draw a line/polygon on the map. This can be combined with TurfJoins.pointsWithinPolygon() to find certain data/Features within the search polygon. The drawn line could also be combined with the Mapbox MapMatching API to clean up the handdrawn line.

ezgif com-resize

@langsmith langsmith self-assigned this Mar 4, 2019
@langsmith
langsmith requested a review from osana March 4, 2019 06:17
@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch from 0ec2f58 to 3dd76a8 Compare March 4, 2019 06:18
@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch 4 times, most recently from 5ac2a21 to 9db590c Compare March 29, 2019 23:26
@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch from 9db590c to 0e0250b Compare April 12, 2019 00:44

@LukasPaczos LukasPaczos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Besides below comments, could you try to limit the usage of the MapboxMap#getStyle and pass the loaded style object around instead to encourage best practices wrt Style object usage?

@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch from 0e0250b to 8bdbebe Compare May 15, 2019 17:14
@langsmith

Copy link
Copy Markdown
Contributor Author

pass the loaded style object around instead to encourage best practices wrt Style object usage

Done

@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch 2 times, most recently from f3835cb to 20c6424 Compare May 15, 2019 17:56
@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch 2 times, most recently from 2045e78 to 59cd093 Compare May 29, 2019 23:54
@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch from 59cd093 to 96c5dc5 Compare May 30, 2019 00:03
@langsmith

Copy link
Copy Markdown
Contributor Author

Ok @LukasPaczos . Finally got around to finishing up refactoring on this. Re-based into the latest commit.


// If drawing polygon, add the first screen touch point to the end of
// the LineLayer list so that it's
if (!drawSingleLineOnly) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not needed case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed because the example offers a button to toggle between drawing just a line or drawing a line+polygon.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The line geometry doesn't have to be closed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, the source doesn't seem to be updated after this addition anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed because the example offers a button to toggle between drawing just a line or drawing a line+polygon.

Made ⬆️ comment because I was looking at the wrong if (!drawSingleLineOnly) { statement.

Regarding the one you're talking about, I close the line geometry because if I don't, the end result of drawing a polygon looks like 👇

device-2019-05-30-105345

I'd rather close the line geometry to have it follow all edges of the polygon (see below), rather than the line geometry being "open".

device-2019-05-30-105942

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah alright, this makes perfect sense.

@langsmith
langsmith force-pushed the ls-adding-drag-to-draw-example branch from 3e275bb to 9a570c0 Compare May 30, 2019 13:45
@langsmith

Copy link
Copy Markdown
Contributor Author

Ok, @LukasPaczos . Did another round of edits based on your review.

@LukasPaczos LukasPaczos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚢

@langsmith
langsmith merged commit b205a1b into master May 31, 2019
@langsmith
langsmith deleted the ls-adding-drag-to-draw-example branch May 31, 2019 14:35
@langsmith langsmith mentioned this pull request Jun 13, 2019
4 of 5 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants