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

add offline map options to mapbox #359

Closed
2 tasks done
andrekir opened this issue Feb 1, 2022 · 14 comments · Fixed by #391
Closed
2 tasks done

add offline map options to mapbox #359

andrekir opened this issue Feb 1, 2022 · 14 comments · Fixed by #391
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@andrekir
Copy link
Member

andrekir commented Feb 1, 2022

Mapview

@garthvh
Copy link
Member

garthvh commented Feb 1, 2022

@joshpirihi there is some interest in doing the same thing you did for the iOS app in android app, can you help @andrekir with any tile questions he runs into? @thebentern has volunteered to do some android testing.

QGIS is the application we have been using to make the maps, the built in OpenStreetMap layers are a good place to start.

@joshpirihi
Copy link

Happy to help! From what I could tell, MapBox doesn't have native support for local mbtiles map files.

But I have seen a hack where you run a local http server on some random port (on the device), and tell the mapbox sdk that is a network source of mbtiles data.

@andrekir andrekir added enhancement New feature or request help wanted Extra attention is needed labels Feb 2, 2022
@PWRxPSYCHO
Copy link
Member

PWRxPSYCHO commented Feb 5, 2022

Mapview

* [ ]  migrate to mapbox API v10 ([Installation](https://docs.mapbox.com/android/maps/guides/install/), [Migrate to v10](https://docs.mapbox.com/android/maps/guides/migrate-to-v10/))

* [ ]  add option to import map tiles / offline maps

I've gotten some of the map migrated over to V10.

Still need to fix the following:

  • Gesture Controls
  • Adding Image,Source & layers
  • Updating Nodes
  • Camera Movement
  • Remove old dependency

I can open a PR with the changes so far. @andrekir

@andrekir
Copy link
Member Author

andrekir commented Feb 5, 2022

I can open a PR with the changes so far.

@PWRxPSYCHO great! please do.

@PWRxPSYCHO
Copy link
Member

PWRxPSYCHO commented Feb 10, 2022

So I've been reading some of the documentation about the offline maps and the first "road-block" I've run into is determining the Geometry for an offline region.

There are 3 approaches that I think we could do.

  1. We could define a list of boundaries for States/Countries.
  2. We allow a user to draw a region on the UI
  3. We set specific Zoom levels (5miles, 10 miles, 15 miles) [Those numbers are arbitrary and can change] this would be a square that covers the region.

Right now I think 3 would be the best approach.
It would limit file sizes and should be the easiest to implement from a UI perspective. (OnX Hunt uses an approach similar to this)

Option 2 would require more UI work but could allow a user to set their own "oddly-shaped" region. However the file sizes could get quite large and we will need to think of some limiting params.

Option 3 would be an on-going update. Once we set bounds we could add them to a list of regions that could be handled similarly to OSMAND. File size would be the largest for this option.

@joshpirihi
Copy link

How easy/hard is it to load a custom offlineable map into MapBox? My use case is I work on a farm with pretty patchy cell coverage. I drew a farm map in QGIS and added support to Garth's iOS app to store that locally, so it works great for me on my iPhone, but the boss has android and would like the same thing.

Meshtastic iOS supports a single .mbtiles raster file for this purpose.

I'm happy to give it a go, but if there's a switch that can be toggled or something easy like that then that would be even better!

@PWRxPSYCHO
Copy link
Member

@joshpirihi I'll have to look into .mbtiles. I'm not sure what the properties are on that file and if we can convert them over to what the offline manager needs to load the map (I would assume it is possible).

MapBox V10 Offline Android SDK

@joshpirihi
Copy link

It's a really nice little format actually. It's just a sqlite file with 2 tables: metadata and tiles. Super easy to query for the tile data (has row, col, scale columns) and metadata has the bounds and zoom range and other stuff.

@PWRxPSYCHO
Copy link
Member

I will investigate this option and see what I can do! It looks like MapBox has an example one I can mess around with which is perfect

@PWRxPSYCHO
Copy link
Member

PWRxPSYCHO commented Feb 21, 2022

I've been chugging along at this and I think I'm about 75% of the way through getting something working. (There are a few menus/quality of life improvements I need to make still).

But I was reading into .mbtiles and I found that no mobile SDK can use them directly. MBTiles.

Directly from that link:
"Note that the mobile SDKs do not support offline use of MBTiles directly. MBTiles can be used offline if they are part of a published Mapbox style."

I took this into consideration when trying to design the prototype offline-capability. A user would have to use a URI from their custom MapBox Style in order to download a specific area/location/overlay/etc in order to use MBTiles. Otherwise, they will be able to select a point on the map and download that region directly with their device.

For example: this Mapbox Style (mapbox://styles/pwrxpsycho/ckzrtyx12000514quk5ehz1tw) incorporates the sample trails.mbtiles into its style which can then be downloaded onto the app and loaded as an offline region.

Preview link of sample style

@joshpirihi
Copy link

This sort of thing makes me really despise Mapbox! It seems a little bit ironic that the only way to have an offline map is to first upload it to the internet.

I did find this which is a bodge that might improve offline mbtiles support. It is a shame that Mapbox don't have first class offline support for their own file format (MapLibre, the open source fork of Mapbox SDK, does support offline mbtiles as a native source )

That said, thanks for all the good work you're doing! I do appreciate it and don't want to direct any ill feelings towards the meshtastic dev team here, you guys are awesome! I realise we're a bit stuck with Mapbox for now and I don't have the time to help with this issue.

@joshpirihi
Copy link

Then again, I am that weirdo with my own map that I drew up. Your current approach will work well for most users, which is good

@garthvh
Copy link
Member

garthvh commented Feb 21, 2022

Do we know what are our current MapBox api limits are? I saw 15,000 on an old thread but that seems really low (i get 250,000 in TestFlight on iOS, and essentially unlimited in the App Store for my $99 a year developer account). Looks like the mapbox offline api is .25 cents per 1000 tiles if you use the ability to draw the region.

@andrekir
Copy link
Member Author

@garthvh good question. for now free tier for online maps (Maps SDKs for Mobile) is up to 25K monthly active users and for offline maps up to 200,000 monthly tile requests.

https://www.mapbox.com/pricing

@andrekir andrekir linked a pull request Mar 12, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants