Skip to content
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

Route and highlighted building are removed after changing style. #2545

Closed
MaximAlien opened this issue Aug 17, 2020 · 3 comments · Fixed by #3736
Closed

Route and highlighted building are removed after changing style. #2545

MaximAlien opened this issue Aug 17, 2020 · 3 comments · Fixed by #3736
Assignees
Labels
bug Something isn’t working UI Work related to visual components, Android Auto, Camera, 3D, voice, etc.
Milestone

Comments

@MaximAlien
Copy link
Contributor

After dynamically changing style in NavigationMapView current route and highlighted building are getting removed. It is expected that current route and highlighted building remain on NavigationMapView. Example:
output

@MaximAlien MaximAlien added bug Something isn’t working UI Work related to visual components, Android Auto, Camera, 3D, voice, etc. labels Aug 17, 2020
@MaximAlien MaximAlien self-assigned this Aug 17, 2020
@MaximAlien MaximAlien changed the title Route and highlighted building is removed after changing style. Route and highlighted building are removed after changing style. Aug 17, 2020
@1ec5
Copy link
Contributor

1ec5 commented Aug 18, 2020

It is expected that current route and highlighted building remain on NavigationMapView.

By design, changing the map style blows away any map style customizations, including the route line and highlighted building style layers. RouteMapViewController is currently responsible for restoring the route line and intermediate waypoint layers by calling show(_:legIndex:). We should ensure that it also restores the building layer.

By coincidence, this issue doesn’t affect the final destination waypoint, which is marked by a point annotation, because annotations do persist across style changes. mapbox/mapbox-gl-native#6180 tracks enabling style layers to persist across style changes like annotations do.

@MaximAlien
Copy link
Contributor Author

In scope of this fix I've added style observation for NavigationMapView as well. Since NavigationMapView can be used independently from NavigationViewController fix inside RouteMapViewController will not cover all cases. Even though in case if style changes several times all subsequent calls to highlightBuildings(at:in3D:) will not perform any further work if layer is already present. Please let me know if you have better ideas or see other edge cases here.

@1ec5
Copy link
Contributor

1ec5 commented Aug 19, 2020

Since NavigationMapView can be used independently from NavigationViewController fix inside RouteMapViewController will not cover all cases.

This is also true of the route line and runtime styling in general. I think it would actually be confusing for some runtime styling to persist but not these specific runtime styling customizations. Better for runtime styling to behave consistently, so that the developer knows to call all the relevant runtime styling methods, including highlightBuildings(at:in3D:), in their MGLMapViewDelegate.mapView(_:didFinishLoading:).

For example, consider an application that would normally add a fill layer representing an isochrone to the map in MGLMapViewDelegate.mapView(_:didFinishLoading:). Being responsible for calling methods like NavigationMapView.show(_:legIndex:), it could do so in the correct order to keep the route line layer from underlapping the isochrone layer. On the other hand, if an anonymous observation block in NavigationMapView were to automatically reapply the route line layer etc., the developer would likely need to search for those layers by identifier in order to insert the isochrone layer beneath them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working UI Work related to visual components, Android Auto, Camera, 3D, voice, etc.
Projects
None yet
2 participants