-
Notifications
You must be signed in to change notification settings - Fork 28
[Public transport] Display basic route results on the map #357
Conversation
a043154
to
225a3d8
Compare
src/adapters/scene_direction.js
Outdated
@@ -73,8 +74,11 @@ export default class SceneDirection { | |||
if (isActive) { | |||
mainRoute = route; | |||
} | |||
this.map.setFeatureState({ source: `source_${route.id}`, id: 1 }, { isActive }); | |||
const geoJson = this.getRouteGeoJson(route.geometry, isActive); | |||
this.map.getSource(`source_${route.id}`).setData(geoJson); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that using setFeatureState
is not practical to update multiple features.
But reloading the whole geoJson data seems to be significantly slower.
Maybe another solution could be to define a routeId property in the features, and update the layer style (to set the line-color
rule dynamically) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! 👌
I did it with the second alternative, as it didn't require manipulating each feature independently, requires a lot less code, and we already did something similar for the pedestrian case.
Now it's generic and snappy :)
ALTERNATE_ROUTE_COLOR, | ||
], | ||
'line-color': route.isActive ? MAIN_ROUTE_COLOR : ALTERNATE_ROUTE_COLOR, | ||
'line-color-transition': { duration: 0 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that for iso-functionnalilty, because otherwise there is a 300ms transition effect which wasn't in the current version. We can drop it later if we decide the transition is nice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arf, I was about to approve the PR, but the test needs to be updated too ;)
9df9d8b
to
963df25
Compare
Probably easier to review commit by commit
Description
Displays public transport route results on the map, for now with the basic style, i.e. without any distinction of step type, metro line color, etc.
As public transport result geoms are GeoJSON FeatureCollection (and not unique geometries like car/walking/bike), we clean and refactor some stuff to be able to manage all results in a generic way, independently of the routing mode:
Why