mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
478 stars 134 forks source link

Add Support for MapWithContentTemplate for Android Auto #2426

Open kszalairh opened 4 months ago

kszalairh commented 4 months ago

New Feature

Google has introduced a new type of template to use with Android Auto starting with 1.7.0-alpha01 of androidx.car.app called MapWithContentTemplate. This is a replacement for RoutePreviewTemplate, PlaceListNavigationTemplate, and MapTemplate. This template allows a Map to be shown with either a ListTemplate, GridTemplate, PaneTemplate, or MessageTemplate at the same time, allowing for tasks to be done with fewer steps inside of an Android Auto app.

The mapboxMapInstaller does run, and I can see the map when I launch my app, and I can control aspects of the map with code (e.g. flyTo Point I give it), but I am unable to receive any events from the DefaultMapboxCarMapGestureHandler. I even tried taking the approach used in this PR of overriding the SurfaceCallback passed to the Map, and I assume there's probably something that needs to be added for supporting this template since it is brand new. Currently the MapboxCarMap supports NavigationTemplate, RoutePreviewNavigationTemplate, and PlaceListNavigationTemplate, and I think adding support for this type of template would be valuable for apps that aren't specifically Navigation based.

Why

Since this is a new template being introduced, and it is meant to be a replacement for one of the currently supported templates, I think it would be useful to add support for so Navigation apps update the version of the Car App library they're using, they can make use of this template. Supporting this template would also allow Point of Interest apps to make use of MapWithContentTemplate which will allow for different types of Android Auto apps to be built that aren't focused solely on Navigation.

jush commented 4 months ago

Thanks for filling in a feature request.

We'll track it internally (ticket MAPSAND-1730) and report back here.

mj09 commented 3 months ago

Just FYI this works fine as it is you just need need to add an action strip to the new MapController you create for the MapWithContentTemplate and give it the PAN action to be able to zoom and move around