-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix map controls and resolve Analyses Message issue #1205
base: 902-ea-breakout
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for veda-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
||
if (isDrawing) { | ||
mbDraw.changeMode(DRAW_POLYGON); | ||
if (main.loaded()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see; so the problem was that we couldn't guarantee that the map was loaded before registering mapbox-draw-related events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think the issue came from two places:
- We couldn’t guarantee the map was fully loaded before adding the Mapbox Draw events. So I added this check to make sure
main.loaded()
istrue
before switching modes whenDrawControl
is initialized - There was a strange synchronization issue in the previous code that initialized
useControl
. Specificallycontrol.current
wasundefined
later in theCustomAoiControl
and adding safeguards or null checks didn't fix the problem. So I ended up assigning the control instance returned byuseControl
directly to a variable (likeconst drawControl = useControl(...)
) to make sure we're always using the correct and initialized control instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh- interesting. It will be great to figure out why 2. is happening (not a blocker, though!)
|
||
if (isDrawing) { | ||
mbDraw.changeMode(DRAW_POLYGON); | ||
if (main.loaded()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh- interesting. It will be great to figure out why 2. is happening (not a blocker, though!)
} else { | ||
mbDraw.changeMode(SIMPLE_SELECT, { | ||
featureIds: mbDraw.getSelectedIds() | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like changeDrawMode
is getting called no matter what, do we want that? I'm wondering can we check for the isDrawing
bool earlier - on line 330? Then this kind of makes the if/else with defaulting to simple_select obsolete but did that do anything anyways? I checked locally and if we got rid of that logic, seems like everything still works as is but I may be missing something 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original commit addressed an issue where polygons were not being selected after completing the drawing by double-clicking. I tried this and it is reproducible locally using this line.
However you're correct that the switch to simple_select
mode is redundant as it seems to be managed internally by Mapbox Draw GL (note: the explicit switch might have been needed back when the fix was implemented). So this behavior makes chunks of the code unnecessary. I removed the obsolete parts and added a comment.
Related Ticket: #1155 #1172
Related Next.js PR: developmentseed/next-veda-ui#7
Description of Changes
Notes & Questions About Changes
{Add additonal notes and outstanding questions here related to changes in this pull request}
Validation / Testing