开发者

iOS Mapkit - Cache maps?

开发者 https://www.devze.com 2023-04-11 20:40 出处:网络
I need maps of certain areas available when no internet connection is available. It would be like this:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消