You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: Infinite Loop when Changing Mode in onStop with draw.create Event
Description:
I'm encountering an infinite loop issue when trying to switch to a custom mode after completing a drawing using mapbox-gl-draw.
When the drawing is finished, my onStop function is triggered, where I fire a draw.create event. After that, I attempt to change the mode to a custom mode using changeMode(). However, this results in a recursive loop with the following error:
mapbox-gl.js?v=40f4fdd7:1833 Uncaught RangeError: Maximum call stack size exceeded
at Map.fire (mapbox-gl.js?v=40f4fdd7:1833:15)
at CustomDrawRectangle.onStop (mono.ts:123:14)
at Object.stop (@mapbox_mapbox-gl-dr…s?v=40f4fdd7:939:14)
at Object.stop (@mapbox_mapbox-gl-dr…s?v=40f4fdd7:178:27)
at Object.changeMode (@mapbox_mapbox-gl-dr…?v=40f4fdd7:1090:17)
at api.changeMode (@mapbox_mapbox-gl-dr…?v=40f4fdd7:3425:16)
at Map.<anonymous> (roof-zone.vue?t=1737448820365:79:16)
at Map.fire (mapbox-gl.js?v=40f4fdd7:1838:39)
at CustomDrawRectangle.onStop (mono.ts:123:14)
at Object.stop (@mapbox_mapbox-gl-dr…s?v=40f4fdd7:939:14)
Steps to Reproduce:
Start drawing using a custom mode (e.g., CustomDrawRectangle).
When the drawing is completed, onStop is triggered.
In onStop, I fire a draw.create event and immediately call changeMode() to switch to another mode.
This results in an infinite recursive loop and the error above.
Expected Behavior:
I expect to be able to switch to another mode without triggering a recursive loop.
Actual Behavior:
Calling changeMode() inside onStop causes an infinite loop.
Code Snippet:
CustomDrawRectangle.onStop=function(){this.map.fire('draw.create',{features: [this.feature]});this.changeMode('custom-mode');// Switching mode triggers an infinite loop};
Environment:
mapbox-gl version: 3.9.3
mapbox-gl-draw version: 1.5.0
Possible Cause:
It seems like changeMode() internally calls stop(), which in turn calls onStop again, causing a loop. Perhaps an internal mechanism prevents mode changes inside onStop?
Suggested Fix:
Is there a recommended approach for switching modes after drawing is complete? Should there be a debounce or asynchronous delay before calling changeMode()?
Any insights or workarounds would be appreciated!
The text was updated successfully, but these errors were encountered:
Title: Infinite Loop when Changing Mode in onStop with draw.create Event
Description:
I'm encountering an infinite loop issue when trying to switch to a custom mode after completing a drawing using
mapbox-gl-draw
.When the drawing is finished, my
onStop
function is triggered, where I fire adraw.create
event. After that, I attempt to change the mode to a custom mode usingchangeMode()
. However, this results in a recursive loop with the following error:Steps to Reproduce:
CustomDrawRectangle
).onStop
is triggered.onStop
, I fire adraw.create
event and immediately callchangeMode()
to switch to another mode.Expected Behavior:
I expect to be able to switch to another mode without triggering a recursive loop.
Actual Behavior:
Calling
changeMode()
insideonStop
causes an infinite loop.Code Snippet:
Environment:
Possible Cause:
It seems like
changeMode()
internally callsstop()
, which in turn callsonStop
again, causing a loop. Perhaps an internal mechanism prevents mode changes insideonStop
?Suggested Fix:
Is there a recommended approach for switching modes after drawing is complete? Should there be a debounce or asynchronous delay before calling
changeMode()
?Any insights or workarounds would be appreciated!
The text was updated successfully, but these errors were encountered: