DroidPlanner / Tower

Ground Control Station for Android Devices
https://play.google.com/store/apps/details?id=org.droidplanner.android
Other
616 stars 555 forks source link

Discontinue old API used for Mapbox projects/classic, replace with Mapbox Studio styled raster tiles #1902

Open OlavAa opened 4 years ago

OlavAa commented 4 years ago

Mapbox integration was faulty after Mapbox discontinued their "Projects" and stopped developing Mapbox Classic. New solution for map designers (or anyone interested in creating a free account to use their services) is Mapbox Studio. Tower threw error messages of incorrect credentials, but could partly display mapbox maps if . was entered into Tower Map ID field.

This pull request solves the error messages by switching out the API to retrieve raster tiles from styles. API documented here: https://docs.mapbox.com/api/maps/#retrieve-raster-tiles-from-styles To support this API, a field to capture the users mapbox user name is introduced. In addition, the mapId field is re-used to enter the ID of the style rather than the mapId. Two API calls to retrieve additional "markers" and "polygons" are disabled since I had problems to support that and saw no obvious use case. But if these objects are included into their mapbox style, they will be retrieved by Tower anyway. In addition, the leak canary is disabled in this PR.

Solution works almost flawless. One problem remains: When user select the flight data screen, the style tiles are not shown. Seems to be caused in DroneMap.java, where use case start flight data only trigger function onStart(), while use cases starting editor/history/"flip orientation" all have a preceding call to onCreateView() upfront of onStart(). The workaround in flight data screen: Rotate device (horisontal <=> portrait), and mapbox tiles becomes visible again.