Wednesday, January 12, 2011

iPhone MapKit Framework to cache Google map for offline: Good Idea

1) Can MapKit Framework support caching Google Map on iPhone locally ? 
2) Can MapKit Framework support to use offline map during GPS-ing ?


Answer :
Unfortunately no, you cannot cache the google tiles (at least not in iOS 4.x). However, you can use an MKOverlay to create an overlay that displays and caches tiles from another map source like OpenStreetMap. Apple published an example TileMap overlay with their 2010 WWDC videos.


Reference link:
http://stackoverflow.com/questions/3792532/iphone-mapkit-framework-to-cache-google-map-for-offline-use


Q. I am working on GPS Track...but when my device is offline then not show the Map. Can you please help for shut out it ? or How to implement the tiles in my application ?
Answer preferred by Apple forum.
Answer 1. : As I understand it MapKit terms and conditions require Google, try route-me for an alternative framwork.


Answer 2. : MapKit maintains a fixed-size map tile cache that contains (roughly speaking) tiles for the most recently viewed areas.  If the device is offline, and your MKMapView is zoomed to an area for which there are no tiles in the tile cache, maps will not be available.

The only solution to this would be to bundle your own map tiles with your app and implement your own map view.  It's up to you to decide if that is worthwhile for your use case.

Thursday, January 6, 2011

Time difference between two different times.

NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
[dateFormatter setDateFormat:@"hh:mm:ss"];
NSDate* firstDate = [dateFormatter dateFromString:starttime];
NSDate* secondDate = [dateFormatter dateFromString:endtime];
NSTimeInterval ti = [secondDate timeIntervalSinceDate:firstDate];
//NSString *str1 = [NSString stringWithFormat:@"%d",ti];
//NSLog(@"str1 %@",str1);
NSUInteger h, m, s;
h = (ti / 3600);
m = ((NSUInteger)(ti / 60)) % 60;
s = ((NSUInteger) ti) % 60;
NSString *str = [NSString stringWithFormat:@"%d:%02d:%02d", h, m, s];
//NSLog(@" strdiff : %@ ",str);