mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.37k stars 1.33k forks source link

Offline maps #584

Closed ljbade closed 8 years ago

ljbade commented 9 years ago

It is a personal goal to have the ability to view maps without needing an Internet connection.

Very useful for activities such as bushwalking our mountain biking.

Plus we know there are others interested in this feature too.

tikimcfee commented 8 years ago

@twbell

Just wanted to say thanks for the response to our questions. It's really a treat to hear back so quickly from the community! It's also great to see the strategy being adopted here, giving us an understanding of where we can place our goals and implementation strategies on our own roadmap.

ryandury commented 8 years ago

Thank you for being in touch with us about this.. This is an exciting feature and would be an essential component in the region that my app will be utilized.

zugaldia commented 8 years ago

Related: https://github.com/mapbox/mapbox-gl-native/pull/3424

MarthzElena commented 8 years ago

Hi all! I'm really excited about this feature because is really necessary for the app I'm currently working on, and I'm already a user of mapbox so I really like how it works. I was wondering do you have any release dates (even for beta) for the offline maps feature on Android and/or iOS?

twbell commented 8 years ago

Thanks @MarthzElena, @ryandury, @tikimcfee we're saying "Q1" now. This feature is critical for our plans too. Expect a more refined date on this thread when we can lock it in with unassuming confidence.

rsimenok commented 8 years ago

Guys, i still don't understand does mapbox supports offline maps for iOS? On my device, iPod Touch 6 Gen, once i open maps, cached some location, reopen app, it's ok. Tomorrow i open maps and see black screen, what can it be? Thank you.

friedbunny commented 8 years ago

The iOS SDK (mbgl, really) has passively cached requests for quite some time, but this cache is not guaranteed and is subject to expiration, etc. This is not what we call "offline support" and it is not directly configurable by the developer.

Offline support means that the developer will be able to explicitly download and store all the necessary assets for a specified area. This is not implemented yet and is what we're working on currently.

rsimenok commented 8 years ago

@friedbunny Thank you for clear answer! I look forward to offline support :)

gpsml commented 8 years ago

Hi! How soon will you be able to show results with offline map in mapbox gl? And Will caching feature for custom areas on the map able in new builds?

twbell commented 8 years ago

@gpsml we're talking about a Q1 release for this feature so you should see something in or before March.

jmcazaux commented 8 years ago

Hi guys, I am really looking forward to this feature as it would allow me switching to Mapbox & vector tiles which would really be a plus.

Just to make sure that this would be a fit, I have 2 questions though:

Many thanks for your reply.

JM

jfirebaugh commented 8 years ago

In the first release of offline, an offline region will be specified by style URL, bounding box, and zoom range. We may add polygonal regions in a future release. We don't plan to support filtering individual vector tile features because the idea is that an offline map should work exactly the same as an online map, minus network traffic. Therefore if you want filtered vector tiles you will need to make your own tileset.

jmcazaux commented 8 years ago

@jfirebaugh many thanks for you answer.

When you say "you need to make your own tileset" what do you mean?

Provided once could easily build a vector MBTiles file, could we "feed" it into the library for off mine use ?

Many thanks for any hint, JM

jfirebaugh commented 8 years ago

I mean construct vector tiles containing the data you want, and upload them to mapbox.com or host them yourself. That way the same tiles are used online and offline.

The initial release of offline will not support importing a preexisting offline database. We may add support for that in a future release.

mb12 commented 8 years ago

@jmcazaux You can use mapbox vector tiles and your own style to filter out anything you do not wish to render.

https://www.mapbox.com/mapbox-gl-style-spec/#types-filter

twbell commented 8 years ago

@jmcazaux note that the system will have limits on what can be downloaded for offline use, and it will be smaller than a country. There will be size and performance constraints; guidance will follow.

gmaclennan commented 8 years ago

Thank you for all the updates on this. One further question: will we be able to use local vector tiles, rather than downloading from a server? We will be building vector tiles dynamically in the app and want to render with mapbox-gl-native.

jfirebaugh commented 8 years ago

Downloading is always via tile URL. If you want to generate tiles locally, run a local server and set the tile URL to a localhost URL.

2ndGAB commented 8 years ago

@twbell I don't really agree. Sure there are limitations but how do Sygic or TomTom do?

twbell commented 8 years ago

@2ndGAB suggest we hold fire on debating this until I post more details on what the bounds on this feature will be.

arifklk commented 8 years ago

Hello all, I am also very excited for offline support. Several weeks ago I sent an email to support team and they told me to planning to announce Offline Maps end of this month. Is it too early? Because as I see from messages Offline Usage is a work for Q1.

It is kind of critical for us because we are building our project on offline maps and it would be great if it is possible to see a beta or something like that? Thanks.

twbell commented 8 years ago

Q1; we'll announce here when we can put a stake in the ground publicly.

twbell commented 8 years ago

Targeting release last two weeks of March; I will refine that window further, and give preliminary visibility, when I know more.

nnhubbard commented 8 years ago

At any point are we able to beta test this? Or perhaps get a preview or list of all the features that offline will have?

twbell commented 8 years ago

give preliminary visibility, when I know more

Will release docs/capabilities as soon as I have them. Do not intend to do a public beta; focus instead on a timely release.

lucaswoj commented 8 years ago

@nnhubbard As always, you are welcome to test our code and track our progress in the offline branch. :smile:

nzhuk commented 8 years ago

@twbell Thanks for the update!

speechlogger commented 8 years ago

Will referring the map's source to local on-device raster-tiles through the style json not work offline? Does the SDK need to verify online the access-token before making the map work, even if it doesn't use Mapbox hosted maps?

jfirebaugh commented 8 years ago

An access token will be required only when downloading resources from Mapbox APIs.

If by "local on-device raster-tiles" you're referring to the use of asset:// URLs, no -- offline will not support asset:// URLs (asset:// URLs are already inherently "offline"). But if the tiles are served by a local server with localhost URLs, they will work with offline the same as other http URLs.

jfirebaugh commented 8 years ago

⇢ #3715, #3891, #3892

nnhubbard commented 8 years ago

Since this was closed, do we have a release date?

JonasVautherin commented 8 years ago

They said in March! ;-)

twbell commented 8 years ago

Tracking progress and feedback on Offline here: https://github.com/mapbox/mapbox-gl-native/issues/4178

rm3dbeckers commented 8 years ago

We've recently tested it and although it looks like the mapView itself accepts styleURLs looking like "asset://style.json" (they load and the tiles are being requested correctly), but the class OfflineTilePyramidRegionDefinition only seems to accept styleUrls of the form "mapbox://styles/mapbox/streets-v9". styleURLs pointing into the assets seem to later cause an error like getHost() called on null reference (or something along that line) and then result in a termination from within the mapbox-gl.so

zugaldia commented 8 years ago

@rm3dbeckers could you open a separate ticket to track this issue? Thanks for the feedback.

kkaefer commented 8 years ago

@rm3dbeckers asset:// URLs are already offline, so they shouldn't be stored in the cache.

rm3dbeckers commented 8 years ago

The problem is that I don't have any tiles in the assets but just the style.json which I want to use to download tiles. But using asset:// urls for the styleURL seems to only work for the mapview itself, not for the OfflineTilePyramidRegionDefinition.

btw: I've created an extra ticket at https://github.com/mapbox/mapbox-gl-native/issues/5271 as requested.

Stophface commented 7 years ago

Is there mbtiles for ios and/or android?

nitrag commented 7 years ago

Chrckout openmaptiles. They have an extension for this. Here, no.

On Fri, Sep 29, 2017 at 11:19 AM Christoph notifications@github.com wrote:

Is there mbtiles for ios and/or android?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mapbox/mapbox-gl-native/issues/584#issuecomment-333155720, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMBkuv48XHtccxWPYiY8PvZVBtylBmkks5snQp0gaJpZM4C5RQr .

Stophface commented 7 years ago

@nitrag thanks for the fast reply. I am searching for ready-to-use mbtiles for iOS or android. Although for android a solution might be osmdroid.

nitrag commented 7 years ago

Pretty sure it's ready to use. You just have to pay them for their module.

On Fri, Sep 29, 2017 at 11:29 AM Christoph notifications@github.com wrote:

@nitrag https://github.com/nitrag thanks for the fast reply. I am searching for ready-to-use mbtiles for iOS or android. Although for android a solution might be osmdroid.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mapbox/mapbox-gl-native/issues/584#issuecomment-333158561, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMBkjJ1PBWDRc5IgEGlNWP6F5vowL75ks5snQzXgaJpZM4C5RQr .

songyuyang0918 commented 5 years ago

Everybody is good! How does the latest IOS SDK load an offline map? I have my own mbTiles file and don't want to download it via MapBox. If there is a plug-in, please give me an address, thank you very much!

tobrun commented 5 years ago

https://docs.mapbox.com/help/troubleshooting/mobile-offline/

ssshake commented 2 years ago

Sorry to be posting on an old issue but I'm not finding a clear answer on the state of this in 2021.

We have a react native app using mapbox-gl-js so I'm realizing now I'm in the wrong repo. We have a need to pre-cache tiles for offline use as we are producing an app to be used on ipad by workers out in remote areas. They need to cache their tiles then go out to the job site.

To complicate matters we also need this cache to be in an application group / shared storage. Which is an ios concept to allow 2 or more applications by the same vendor to access common data storage.

We have two applications, one using mapbox-gl-js and the other using the unity mapbox SDK. The react native application needs to download and cache the tiles in shared storage. The unity application need to be able to access the offline tiles from shared storage.

Any help indicating where to go would be very helpful as I'm finding the number of libraries/sdks for mapbox and the supported feature set between them to be quite unclear. Thanks!

hjhimanshu01 commented 1 year ago

@ssshake, were you able to render maps in offline mode?

ssshake commented 1 year ago

Yes (removed an essay about my specific issues as it's off topic)

hjhimanshu01 commented 1 year ago

@ssshake, thanks for explaining, seems like quite an intricate solution you have got there. What I'm trying to achieve is related to 1), just to cache the tile data in a DB and read it later when offline, though I'm trying to achieve it in iOS using swift. Is it possible for you to just share some pointers on how did you cached those tiles and read it back in mapbox?

Once again thanks for explaining it in so much detail, cheers!

ssshake commented 1 year ago

Ah I see, sorry I thought you were a maintainer of this package trying to fix my issue.

I'm using the react-native-mapbox-gl package but I would hope it has the same methods as the native mapbox GL. You need to create a "pack" and that is implicitly saved to the mapbox sqlite DB.

Something like this:

    MapboxGL.offlineManager.setTileCountLimit(100000)

    await MapboxGL.offlineManager.createPack(
        {
            name: packName,
            styleURL: mapStyleUrl,
            minZoom: 8,
            maxZoom: 16,
            bounds: [
                [furthest.east, furthest.north],
                [furthest.west, furthest.south]
            ]
        },
        onProgress,
        errorListener
    )

Where furthest is an object containing the lat/long bounds that you want. We use two arrays of longitudes and latitudes for all of the points on the map we care about. Then we just get the min and max to construct the bounds.

{
        north: Math.max(...latitudes),
        east: Math.max(...longitudes),
        south: Math.min(...latitudes),
        west: Math.min(...longitudes)
}

I'm redacting some info in my prior comment because it's not helpful to getting my solution and is too off topic.

hjhimanshu01 commented 1 year ago

Perfect, thanks for the info!