mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-20 14:44:51 +02:00
fix: route polyline on first route — use idle event instead of load
The load event only fires once during map init. When route state changes before style is fully loaded, the once(load) handler never executes because load already fired. idle fires after every render cycle, ensuring the route draws once the style is ready.
This commit is contained in:
parent
53d25dafd8
commit
6bf8717803
1 changed files with 2 additions and 2 deletions
|
|
@ -1284,8 +1284,8 @@ const MapView = forwardRef(function MapView(_, ref) {
|
||||||
if (!map) return
|
if (!map) return
|
||||||
if (!map.isStyleLoaded()) {
|
if (!map.isStyleLoaded()) {
|
||||||
const handler = () => updateRoute(map, route)
|
const handler = () => updateRoute(map, route)
|
||||||
map.once('load', handler)
|
map.once('idle', handler)
|
||||||
return () => map.off('load', handler)
|
return () => map.off('idle', handler)
|
||||||
}
|
}
|
||||||
updateRoute(map, route)
|
updateRoute(map, route)
|
||||||
}, [route])
|
}, [route])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue