-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Frontend controlled map style #4937
base: master
Are you sure you want to change the base?
Conversation
src/components/map/Map.tsx
Outdated
setMapRegion((prevMapRegion) => | ||
isEqual(prevMapRegion, newMapRegion) ? prevMapRegion : newMapRegion, | ||
); | ||
if (!isEqual(mapRegion, newMapRegion)) { |
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.
Performance fix. setMapRegion
always triggers a new component re-render, which re-trigger all the hooks. Since MapBox has a bug which triggers onMapIdle way too often, this causes a lot of side effects. If testing indicates that it is needed, we could consider throttling or debouncing as extra safety here.
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.
Maybe a stateless var instead. But perhaps is needed to be in that way.
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.
Not really sure this has any effect 🤔 Since setting prevMapRegion
should already not invoke rerender. It's not invoking the setter that causes rerender, but that the state has changed.
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 like this suggestion!
It is possible to change the mapRegion state to a ref instead, and update vehicles and stations directly instead of in a useEffect:
const mapRegionRef = useRef<MapRegion>();
const updateVehiclesAndStations = useCallback(
(mapRegion: MapRegion) => {
if (!mapRegion) return;
mapRegionRef.current = mapRegion;
updateRegionForVehicles?.(mapRegion);
updateRegionForStations?.(mapRegion);
},
[updateRegionForVehicles, updateRegionForStations],
);
and then instead of setMapRegion:
if (!isEqual(mapRegionRef.current, newMapRegion)) {
updateVehiclesAndStations(newMapRegion);
}
Also for onDidFinishLoadingMap
:
updateVehiclesAndStations({
visibleBounds,
zoomLevel,
center,
});
Seems to work well when testing, so I actually prefer this.
However it is another change, so not sure if it should be included in this PR 🤔
@@ -184,6 +191,15 @@ export const Map = (props: MapProps) => { | |||
async (feature: Feature) => { | |||
if (!isFeaturePoint(feature)) return; | |||
|
|||
// should split components instead of this, ExploreLocation should only depend on location state, not features |
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.
Upcoming PR..
{...MapViewConfig} | ||
{...{ | ||
...MapViewConfig, | ||
// only updating Map.tsx for now. |
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.
Upcoming PR for the other maps
Also: There is an override on the status bar color for the map tab that can be removed now. We should have light-content in dark mode and dark-content in light mode, just like elsewhere in the app. |
|
@gorandalum Two reasons for removing the "dotted line from your position to the selected stop" feature, after a discussion between me and @Aliaaen:
.. and of course technically it reduces complexity. |
Closes https://github.com/AtB-AS/kundevendt/issues/19557
Closes https://github.com/AtB-AS/kundevendt/issues/10821
Closes https://github.com/AtB-AS/kundevendt/issues/19451
Closes https://github.com/AtB-AS/kundevendt/issues/19259
First of all excuse the large PR, but it is kinda needed to avoid incomplete/invalid steps along the way 😅
Feel free to ask me for closer explanations if needed!
What's happening in this PR:
Map
component has been updated. That means only the map tab and choose location maps are updated for now.useMapboxJsonStyle
, which uses the files insidemapbox-styles
to get the style locally, but sprites from the url defined in remote config. This only shows geographical features, not NSR items.NationalStopRegistryFeatures
. This is where the NSR items are shown now. In order to access the data, new mapbox env variables have been added.How the zoom logic works:
showAsDefaultAtZoomLevel
is reached, the icon switches to default. The label will then start to fade in as well.Before:

After:
Acceptance Criteria:
- [ ] show a custom pin to indicate the selected element
- [ ] other items should become minimized (apart from scooter clusters, that will be addressed later)
- [ ] first be invisible and tiny in the minimized state
- [ ] then transition to reach full size and have no transparency in the minimized state as you zoom in
- [ ] switch to the default icon
- [ ] the label should then start becoming visible
- [ ] The quays should start small, and when full size is reached, the text should start fading in
- NOTE: different types of stop places are configured to reach these states at different zoom levels