This is my first ever post in this forum, so please be gentle if I go about the wrong way.
I’d like to suggest a new and easily implemented feature that will allow any user to utilize their own “custom” MapBox maps in both planning and flight views.
I had already read through Mapbox’ API specification. And although I’m far from a developer, I decided to get my hands dirty: Installed Qt and patiently worked my way through some of the code. Yesterday I finally had a working solution. But being an absolute newbie, the resulting code is nothing but a hack (I simply re-wrote the current code to do a proof of concept). I need help to implement this in a proper way so that everyone interested can utilize the ability. But the solution does work - with no errors.
I concluded that the key to get map tiles lies within QGCMapEngine.cpp, and that the URL to retrieve Mapbox tiles is constructed there. Currently, the URL is built based on the “Retrieve tiles” API. According to specification, this API also offers the ability to include an optional “style” attribute. But I failed to get this to work.
But then I dicsovered the “Retrieve raster tiles from styles” API. And after some trial and error, QGC now use my own styled version of the maps. Which is key to my use of QGC: I map water depths with an Arduboat. Mapping may take several days of effort, so I need to be able to view temporary maps during the efforts. And like any sailor, the finished map contains key information that I need when planning and executing missions. Depths, plateaus, ridges etc are my points of interests
To get this to work I humbly suggest:
- Add two new attributes: mapboxAccount and mapboxStyle (both text fields)
- Consider to add useMapboxStyle (boolean)
- The boolean should perhaps only be selectable if the two text fields have values
- UI: Alter the settings (currently under “offline maps”, then “options”) for the user to enter values into the suggested fields
Then, in QGCMapEngine.cpp, enter a new section to build the URL for this new API (please read with an understanding that I am no developer)
Condition (pseudo): IF mapBoxToken AND mapboxAccount AND mapboxStyle “all have values” AND useMapboxStyle = true
Then build URL like this:
QString server = “https://api.mapbox.com/styles/v1”;
server += QString(“/%1/%2/tiles/256”).arg(mapboxAccount).arg(mapboxStyle);
server += QString(“/%1/%2/%3?access_token=%4”).arg(zoom).arg(x).arg(y).arg(mapBoxToken);
And finally: Important to also alter the current condition to build mapbox URL. In addition to the current condition, it should only run if useMapboxStyle = false
Done!
Here’s a pict of a running version of QGC displaying a flight map modified by Mapbox studio in my Mapbox account. In Mapbox, I add depth maps as tilesets (one per water), thereafter the tilesets are simply added to a custom map style of my choosing.
Could anyone help implement this???