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

Changing the mode from draw_circle to simple_select on event onTouchEnd throws an error #28

Open
pct-elizabeta-dimovska opened this issue Nov 27, 2023 · 5 comments

Comments

@pct-elizabeta-dimovska
Copy link

When the user draws a circle, after the shape is created the mode needs to be changed to simple select, but instead an error is thrown:

Console error
console error

The code is trying to access Constants.modes.SIMPLE_SELECT
mouse up event

Constant modes doesn't contain property with key SIMPLE_SELECT - it's in lower case.
constants

@zakjan
Copy link
Owner

zakjan commented Nov 28, 2023

Hi, this works for me in the demo. Select draw_circle in the mode select, draw a circle, the mode switches back to simple_select.

Can you debug what's specific in your setup?

@jparish3
Copy link

your demo throws this error with any interaction after initial draw:get_features_and_set_cursor.js:14 Uncaught TypeError: Cannot read properties of undefined (reading 'indexOf')
at N (get_features_and_set_cursor.js:14:18)
at i.mouseup (events.js:63:20)
at Ct.fire (evented.js:119:26)
at i.fire (setup.js:53:24)
at Oo.mouseup (map_event.js:38:19)
at gr.handleEvent (handler_manager.js:325:58)

@Davey-Hughes
Copy link

Hi, I think I'm running into a similar issue. I've tried the demo as well in Chrome, Firefox, and Safari, and on Linux and MacOS. The demo for me shows non-geodesic lines whenever a mode that's not the draw_circle is selected:

image

The object also has an extra field which is "undefined".

In this code: https://github.com/zakjan/mapbox-gl-draw-geodesic/blob/master/src/modes/index.js#L11-L22 what is happening when I step through the browser's debugger is patchDrawLineString(modes[Constants.modes.DRAW_LINE_STRING]) calls the patch function with undefined presumably because Constants.modes.DRAW_LINE_STRING is undefined.

@zakjan
Copy link
Owner

zakjan commented Dec 31, 2023

Hi, the root cause was in incorrect reading existing mapbox-gl-draw modes after upgrading to mapbox-gl-draw 1.4.3. Fixed in f6ca244 and released as 2.3.1. Could you try it?

@zakjan zakjan mentioned this issue Dec 31, 2023
@Davey-Hughes
Copy link

Hi this fix seems to work for me, thanks! I figured it was something better than my hardcoded solution but I'm not as familiar with the mapbox library.

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

No branches or pull requests

4 participants