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:
Matt 2026-04-27 05:01:39 +00:00
commit f031a06eb7

View file

@ -1284,8 +1284,8 @@ const MapView = forwardRef(function MapView(_, ref) {
if (!map) return
if (!map.isStyleLoaded()) {
const handler = () => updateRoute(map, route)
map.once('load', handler)
return () => map.off('load', handler)
map.once('idle', handler)
return () => map.off('idle', handler)
}
updateRoute(map, route)
}, [route])