Commit b7bf7ce
committed
fix(map): preserve map view on entering drawing mode
When activating the drawing mode, the map would zoom out to the
globe level instead of maintaining the current zoom and position.
This was caused by the `setupDrawingTools` function not restoring
the map's view state after adding the MapboxDraw control.
This commit fixes the issue by explicitly restoring the map's center,
zoom, and pitch from a stored reference immediately after the
drawing control is added. A `flyTo` with a duration of 0 is used
to make the transition seamless for the user.
This is wrapped in a `setTimeout` to ensure the view restoration
happens after any asynchronous initialization of the MapboxDraw
control, addressing a potential timing issue.1 parent cba65dc commit b7bf7ce
1 file changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
280 | 284 | | |
281 | 285 | | |
282 | 286 | | |
| |||
0 commit comments