Open ankiimation opened 1 year ago
I know very little about Android Car APIs, so my answer may be a bit off. But looking at the question at high level, I do not think it is possible without complex workarounds. The issue here is that Carto Mobile SDK needs to configure its rendering surface itself, as there are specific format requirement to depth buffer and stencil buffer in order to provide correct rendering. But NavigationTemplate
gives a preconfigured Surface
instance that may not be configured with these requirements in mind.
A possible workaround would be to render the map using normal MapView
instance (or perhaps TextureMapView
instance) and then copy the rendered image to the surface provided by NavigationTemplate
callback.
I have tried with TextureView but it cant render without attached to a View
Ok, if you need to render map without having a view, you would probably need to make a custom MapView
class. On the positive side, the class can be implemented in Java/Kotlin, no changes in native C++ code are necessary (if you look at https://github.com/CartoDB/mobile-sdk/blob/master/android/java/com/carto/ui/MapView.java, you can see that most of code simply acts as a stub to BaseMapView
, which is implemented in C++). On the negative side, you need to work classes/APIs like EGLDisplay
, EGLContext
that are rather low level.
Perhaps there is also a way to create transparent/invisible MapView
, but I am not sure whether this works.
Ok, if you need to render map without having a view, you would probably need to make a custom
MapView
class. On the positive side, the class can be implemented in Java/Kotlin, no changes in native C++ code are necessary (if you look at https://github.com/CartoDB/mobile-sdk/blob/master/android/java/com/carto/ui/MapView.java, you can see that most of code simply acts as a stub toBaseMapView
, which is implemented in C++). On the negative side, you need to work classes/APIs likeEGLDisplay
,EGLContext
that are rather low level.
@mtehver how would I hook up my custom Carto MapView
class to the SurfaceRenderer.java in the Android auto navigation sample app?
Just a general approach or procedure would be great, thanks.
I'm using the Carto to display maps on my Android application. However, I'm having trouble figuring out how to render the map on the android-auto Navigation Template that already provides a Surface to render on.
Thanks in advance!