开发者

Static maps with routing on iOS

Is there a way to have static maps on the iPhone, with either MapKit or a third-party framework? By this I mean fixed area of开发者_JAVA百科 say, 5 sq miles, which can by zoomed/panned etc, but which doesn't require an internet connection to load the map.

Additionally, is it possible to get route directions, and draw them on the map?


You can of course always roll your own solution with CATiledLayer if the area you want to display is that small, but it's probably better and easier to have a look at routing frameworks like MapBox (http://mapbox.com/blog/introducing-mapbox-ios-sdk/), which provides offline support for iOS.


The MapKit framework doesn't offer offline maps currently.

It is possible to define an area on the maps, and lock the user into that area, but an internet connection is still required.

Maybe a more direct way to do what you want is to download a static image for the zone you are interested in and cache it, using the image of that map area to zoom and pan around in. Of course this would require an initial internet connection but that is really not such an obstacle, after all, one must have a connection to download your application.

You could also provide this image directly into your applications bundle, but you've not really told us much to conclude that the latter option is feasible.

As for routing, it's also not supported currently. You could however retrieve a list of waypoints from point A to B directly from the Google maps remote API - note you cannot do this with MapKit framework.

With these waypoints (which contain coordinates) and the current zoom level value, it's possible for you to plot these points and draw between each one in order to implement your own routing, this get a little ugly or maybe better to say "laggy" when the user begins to zoom in and out as it's only possible to know how to redraw your route when the user ends zooming (lifts their fingers from the screen), but of course like most things in programming, there is a solution to this which is, I feel out of scope for this question.

I hope this helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜