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
476 stars 133 forks source link

Feature Request: Layer for drawing on screen x/y coordinates (for Android Auto use cases) #342

Closed SamuelBrucksch closed 3 weeks ago

SamuelBrucksch commented 3 years ago

I'm currently using Mapbox Maps 10 Beta 19.

New Feature

I want to be able to put a layer on top of all other layers where i can draw on using screen coordinates.

Why

I'm currently using MapSurface with android auto. I pass the given Surface to MapSurface that handles the drawin on the Surface, but i have no possibilities, to modify the result, if i want to draw additional elements like speed limit on top of the map.

Unfortunately Android Auto has only that one layer and no way to add additional UI elements, so they need to be drawn by the app directly on top of the map.

I could not find a way, to do this. If there is one please tell me. If not please add functionality to do so.

I only found ways to add icons when converting x/y coordinates into GPS coordinates, but the overlays i want to draw need to be at a fixed screen position.

We already have a running application, where we draw on top of the map, but now we want to move over to mapbox and this is our only blocker, to do so. The rest works very nicely with AA.

SamuelBrucksch commented 3 years ago

I tried a workaround by converting the x/y coordinates to GPS coordinates and updating them on each frame, but that is also kind of sluggish:

https://user-images.githubusercontent.com/8776268/118861286-9f4ef580-b8dc-11eb-9635-51e910701044.mp4

So we really need a way to draw overlays on fixed screen coordinates.

Also when adding pitch, the images used for those overlays are rescaled (https://github.com/mapbox/mapbox-maps-android/issues/343). Not sure if that is the intended behaviour, but for this use case a layer that is not affected by any map camera settings would be really beneficial.

SamuelBrucksch commented 3 years ago

@tobrun i saw you commented on other issues as well... This is somewhat high on our TODO list, as it's the only thing left from migrating to mapbox completely. Is this the right channel to ask for this feature?

Not sure if you guys have much experience with android auto, but the problem is that there are no views and so on, everything is done with that single surface we get from AA, which is used in MapSurface. So i can not just overlay the map with another view.

You are the first SDK to support AA at all, so kudos for that. I would like to help you on improving this with some real world experience.

SamuelBrucksch commented 3 years ago

Anyone please? I would be willing to open a PR for this if anyone can give me a hint on where i have to start. This is really important for Android Auto usage.

tobrun commented 3 years ago

:wave: @SamuelBrucksch thank you for reaching out and using our products. Apologies for the slow reply :) There is no concrete layer type that works with screencoordinates, with normal Android/iOS integration there wasn't a need for it. The closest thing to "custom" drawing is with using the CustomLayer API. This API allows you to draw opengl content as part of the map. There is a java API as well as a C++ one (https://github.com/mapbox/mapbox-maps-android/blob/main/app/src/main/cpp/example_custom_layer.cpp).

SamuelBrucksch commented 3 years ago

Hi @tobrun,

thanks for pointing that one out, did not find it yet. That one looks indeed like something I could use. However on first check it looks rather complicated to just draw 2-3 overlays like speedlimit sign.

I'm not so familiar with drawing in OpenGL, so this will cause a lot of extra work for me, so my hope was that an additional layer could be introduced.

It's always easy to say it looks like not much work to add it (i know so myself from customer requests ;) ), but i think from what already exists, it should be fairly easy to add an overlay, that behaves like a layer with 0 pitch that uses screen coordinates instead of gps coordinates.

Is there any way, this could be added?

Best Samuel

SamuelBrucksch commented 3 years ago

Hi,

It seems you published android auto samples as well now, which is very good and shows that you now acknowledge this use case. However there still is the problem, that we do not get additional layers for Android Auto and drawing additional elements like speed limit is still only possible in a very annoying way in a custom layer with custom open GL code. I could get it to work somehow but the code is really ugly and I'm not even sure if it is totally correct as i still have some bugs i can not identify. So I'm still waiting for a general solution to draw a layer based on X/Y coordinates that is aligned with viewport and not map.

Is there any progress on this?

@tobrun could you please check if this can be ranked a bit higher? Mapbox works really well on Android Auto and this is the only thing missing to make it even better and a complete solution for maps on AA.

Best Samuel

SamuelBrucksch commented 3 years ago

Btw this is also needed for the Mapbox attribution. Right now there is no possibility to add the Mapbox logo in Android Auto with help of SDK.

tobrun commented 3 years ago

@SamuelBrucksch thank you for reaching out again! We are internally working on an API to support the Android Auto use-case in the best way. This also includes attribution, logo or any other overlain "widget" and having an API to add your own (eg. speedsigns). Tagging in the developer looking into this @pengdev to give updates while we progress the feature.

kmadsen commented 2 years ago

@SamuelBrucksch in case you want to get moving on this, here are a couple items that you can take a look at.

A long term widget api is in progress (as tobrun said), here is a pull request that is moving ​https://github.com/mapbox/mapbox-maps-android/pull/1036

Also, there are two other existing approaches in an examples repository. Feel free to use them and modify them

kiryldz commented 3 weeks ago

Stale, outdated.