11

We have stumbled upon such a problem.

We are developing an application for travelling. To make sure the user doesn't spend much money on roaming charges in our app we decided to implement a settings option for user to view cached maps only. So we let the user decide whether he wants to load the maps from internet or he wants to save money and view cached maps (stored in Library/Caches/MapTiles/MapTiles.sqlitedb).

We can't find a way to implement this. Is there any way to disable network programmatically in this case? Or force MapKit use cached tiles only? We thought about changing APN programmatically for this option to force MapKit go offline. Is it possible to change APN programmatically?

Thank you!

Slava TLM
  • 161
  • 1
  • 1
  • 7

4 Answers4

4

iPhone SDK apps do not have access to the network adapter settings, and I know of nothing in the MapKit API that gives you control over its Internet usage. Your best option in this case is probably to present an alert suggesting that the user enable Airplane Mode or turn off data roaming.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
  • Actually iphone sdk has reachability api which is usefull when you need to know if networking is accessible. – Nik Mar 05 '12 at 19:22
2

use openstreetmap think the commercial side of it Cloud-made allows offline maps

http://developers.cloudmade.com/projects/show/iphone-sdk

Libraries that help iPhone developers use OSM maps route-me is an open-source library used in a number of iPhone applications to display OSM maps. The CloudMade iPhone Maps Library is an open-source library that provides high-level access to CloudMade's OSM-based map tiles with different sizes and different styles. John McKerrell has ported the routing algorithm from gosmore to run on the iPhone and has successfully generated basic routes. More complicated routes crash the iPhone at the moment

brian.clear
  • 5,277
  • 2
  • 41
  • 62
  • Cloudmade will allow you to cache their tiles in the application (using the mercator tile system), however this is not yet supported by the API and you have to write the functionality to do this yourself (for now). – Willster Jan 21 '11 at 00:26
  • dunno if I would go with Cloud-made.. check out why http://stackoverflow.com/questions/7928199/cloudmade-status#comment11002846_7928199 – HurkNburkS Jul 11 '12 at 09:10
1

There are some ways. One is to use your own tile overlay and implement the caching algorithm either in URLForTilePath: or in loadTileAtPath:result:

It works very well with open domain and some private ones. Does not cache the standard Apple Maps.

Another way that will be able to cache everything is subclass NSURLProtocol. There are some tutorials and probably you may detect when is a map image and act accordingly

-1

the google map app does the cache feature ... MapKit seem no , I think Apple will add this feature in next version SDK ...

iXcoder
  • 1,564
  • 4
  • 20
  • 41
  • Actually we are able to view the cached map tiles in our app with no network connection. The problem is that we can't implement a situation where a user sets "offline mode". When this option is selected we need to display cached map tiles, even if there is network connection. So we need to force MapKit use cached tiles and NOT go online. Thx – Slava TLM Dec 25 '09 at 09:36
  • Maybe it is somehow possible to change APN settings when we try to load the map when we are not allowed to. This way the app won't be able to go online and will be forced to use local DB. – Slava TLM Dec 25 '09 at 09:37
  • When the app has no network connection it will pull cached map tiles from the local folder. So no need to make any changes in the code - just follow apple's documentation :) – Slava TLM Jun 22 '10 at 10:33