简体   繁体   中英

iOS Mapkit - Cache maps?

I need maps of certain areas available when no internet connection is available.

It would be like this:

  1. User loads app internet connection is available
  2. App downloads list of coordinates and places pins on the map
  3. User leaves their house and has no internet connection
  4. Pins and map remain readily available for user to interact with, even without internet connection

How do I do this?

You probably won't use MKMapView and MapKit for that, but the Google Maps Static API that allows you to download static images (even with pins on it) directly.

Here is the example given by the Google Maps API doc itself

Then you can store this image and display it in an UIImageView in a UIScrollView for example.

Possibly the above mentioned Google API achieves just this, but another approach is to create a KML file using Google custom maps or some other service and then download and display it. An example can be found here . Alternatively, MapBox has this functionality built in. Go to this webpage , click command-f and search for "offline", and you will find the relevant information. One last suggestion- as an inelegant hack, if no other option works, you could try saving the html of the google maps webpage for the area and then loading that html file from your main bundle into your map view. I have no idea if that would work, but in a last case scenario it would be worth a shot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM