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

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

OlavAa
Copy link

@OlavAa OlavAa commented Aug 13, 2019

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.

OlavAa and others added 7 commits August 10, 2019 19:53
Signed-off-by: oaamaas <[email protected]>
https://api.mapbox.com/styles/v1/

Original API was depending in the phased out approach with Mapbox projects, and the use of the retured Mapbox Classic app.
The API introduced utilizes the current Mapbox Studio's abilities to create styles, and to modify these styles with tilesets and other customizations
The API requires:
- The Mapbox Account name: As introduced in multiple file as mapboxUserId
- The Style ID: Re-used the mapId for this purpose since the old API is phased out anyway
- The Mapbox token, already present in previous versions of Tower

Solution fully working, but has a flaw when user selects "flight data screen" (no flaw in screens for editor and history:
- Tower loads normal maps from Google, but does not overlay the styled tiles
- Workaround: Change orientation of device, and the styled tiles are overlaid
The flaw is caused by logic in DroneMap.java, the following IF concludes wether or not tiles should be overlaid:
if (mMapFragment == null || mMapFragment.getProvider() != mapProvider) (line 294)

Should be corrected, but Mapbox in Tower is now fully functional with the workaround.

Signed-off-by: oaamaas <[email protected]>
Removed import of disabled leakcanary in DroidPlannerApp

Signed-off-by: oaamaas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant