I need maps of certain areas available when no internet connection is available.
It would be like this:
- User loads app internet connection is available
- App downloads list of开发者_运维百科 coordinates and places pins on the map
- User leaves their house and has no internet connection
- 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.
精彩评论