iOS6以éã§ã®Mapã¢ããªã®èµ·åæ¹æ³
ã¯ããã«
ããã§ã¯ãã¢ããªå é¨ã§ä½¿ç¨ãã Map æ©è½ï¼MapKitï¼ã®ãã¨ã¯ç¹ã«è¨åãããã¢ããªããå¤é¨ã® Map ã¢ããªï¼æ¨æº Map.app 㨠GoogleMap.appï¼ã®èµ·åã«ã¤ãã¦æ¸ãã¾ãã
ç¾ç¶
æ¨æº Map.app 㨠GoogleMap.app
iOS 6 以åã¾ã§ã¯ç´æ£ã® Map.app ã¯å é¨ã§ã¯ Google ã使ç¨ããã¦ãã¾ãããiOS 6 ãã㯠Apple ç¬èªã«åãæ¿ãããã¾ããã2013/02/15 æç¹ã§ã¯æ¹åãããã¦ãã¦ã¯ãããã®ã®ä»¥åã® Google ãã¼ã¹ã® Map.app ã¨æ¯ã¹ãã¨å 容çã«è¦å£ãããç¶æ³ã§ãããã㧠Google ãã 3rd Party ã¢ããªã¨ã㦠GoogleMap.app ããªãªã¼ã¹ããã¾ããããã®ã¢ããªã¯æ¨æºã¤ã³ã¹ãã¼ã«ããã¦ããããã® Map.app ããããã¯ã¼ã¢ãããã¦ãã¦è©å¤ã®é«ããã®ã«ãªã£ã¦ãã¾ãã
ãã¼ãº
ãããªãã¨ãã¯ããã¼ãºã¨ãã¦ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
- 使ãããã GoogleMap.app ãå¼ã³åºãã¦ä½¿ããã
- GoogleMap.app ãã¤ã³ã¹ãã¼ã«ãã¦ããªãã¦ã¼ã¶ã¼åãã«ãèæ ®ãã¦æ¨æº Map.app ã使ããã
対å¿æ¹æ³
GoogleMap.app ãéãæåã«é¢ãã¦
- iOS ãã¼ã¸ã§ã³åãã
- GoogleMap.app ãã¤ã³ã¹ãã¼ã«ããã¦ãããã canOpenURL: ã§ç¢ºèªããGoogleMap.app ã§ä»ã¾ã§åããããªæåãããããã¨ãã§ãã¾ããã
iOS æ¨æº Map.app ãéãæåã«é¢ãã¦
- iOS 6 以åã®å ´å
- Map.app ã¯å é¨å®è£ ã Google ã®ãã®ãªã®ã§æã¨åãæåï¼æ¢åã®å®è£ ï¼ã§ Map.app ãéã
- iOS 6 以éã®å ´å
- æ¯è¼çåç´ãªãã©ã¡ã¼ã¿ãªã iOS 6 以åã¨åãã§ãåé¡ã¯ãªããä¸é¨ä»¥åã¾ã§ä½¿ãã¦ãããã©ã¡ã¼ã¿ã使ããªããã®ããã
- iOS 6 ãã追å ããã
MKMapItem
ã¯ã©ã¹ã®æ©è½ã使ã£ã¦ããç´°ãããªãã·ã§ã³ãè¨å®ã㦠iOS æ¨æº Map.app (Apple) ãéã
ã³ã¼ãä¾
iOS ã®æ¨æº Map.app ãéã
/** MKMapItem ã使ããã確èªãã使ããå ´åã¯ãããå©ç¨ï¼äºå®ä¸ iOS 6 以åã以éãã®å¤å®ï¼ 使ããªãå ´åï¼äºå®ä¸ iOS 6.x 以åï¼ã®å ´åã¯æããã®æå */ Class itemClass = [MKMapItem class]; if (itemClass) { /// MKPlacemark ãä½ã CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(self.place.latitude, self.place.longitude); MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:self.place.addressDictionary]; /// MKPlacemark ãã MKMapItem ãä½ã MKMapItem *item = [[MKMapItem alloc] initWithPlacemark:placemark]; item.name = self.place.name; /// Apple Map.app ã«æ¸¡ããªãã·ã§ã³ãæºå /// Span ãæå®ã㦠Map 表示æã®æ¡å¤§çãèª¿æ´ MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coordinate, 250, 250); MKCoordinateSpan span = region.span; /// Apple Map.app ãéã BOOL result = [item openInMapsWithLaunchOptions:@{ MKLaunchOptionsMapSpanKey : [NSValue valueWithMKCoordinateSpan:span], MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:coordinate] }]; if (result == NO) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Apple Map.app ãéãã¾ããã§ãã" delegate:nil cancelButtonTitle:@"éãã" otherButtonTitles:nil]; [alert show]; } } else { NSString *url = [NSString stringWithFormat:@"http://maps.apple.com/?ll=%f,%f&q=%@", self.place.latitude, self.place.longitude, self.place.escapedName]; NSURL *URL = [NSURL URLWithString:url]; [[UIApplication sharedApplication] openURL:URL]; }
MKMapItem
ã® openInMapsWithLaunchOptions:
ã使ãã¨ããç¨åº¦ç´°ããæå®ã Apple Map.app ã«å¯¾ãã¦æ¸¡ãã¾ããopenInMapsWithLaunchOptions:
㧠span ããã¦ãããã¨è¡¨ç¤ºãããæã®å¤§ããï¼ãºã¼ã å
·åï¼ã調æ´ã§ãã¾ããMKCoordinateSpan
ã®å¤ã¯æç³»ã®ç§ã«ã¯ããåãããªãæãã§ããå®éã®å©ç¨ã·ã¼ã³çã«ã¯ãä»»æã®å°ç¹ã軸㫠500m ãããã®ç¯å²ã§è¡¨ç¤ºããããã¨ããã®ãå¤ãã¨æãã¾ãããã®ã¡ã¼ãã«ã§æå®ããã«ã¯çä½ã§ããå°çãèæ
®ãã¦ããã¬ãããã¬ãã¨ç§ã«ã¨ã£ã¦ã¯ããåãããªãè¨ç®ãããªãã¨ãããªãã§ããç°¡åã«æ¸ã¾ããæ¹æ³ã¨ãã¦ã¯ MKCoordinateRegionMakeWithDistance
é¢æ°ã使ã£ã¦å¾ããã MKCoordinateRegion
ãã MKCoordinateSpan
ãåå¾ããã®ãç°¡åã§ããããããã§ãã
Google Map.app ãéã
ãã¡ããåèã« URL Scheme ã使ã£ã¦ Google Map.app ãéãã
NSString *url = [NSString stringWithFormat:@"googlemaps://?q=%f,%f(%@)", self.place.latitude, self.place.longitude, self.place.escapedName]; NSURL *URL = [NSURL URLWithString:url]; if ([[UIApplication sharedApplication] canOpenURL:URL]) { [[UIApplication sharedApplication] openURL:URL]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Google Map.app ãã¤ã³ã¹ãã¼ã«ããã¦ãã¾ãã" delegate:nil cancelButtonTitle:@"éãã" otherButtonTitles:nil]; [alert show]; }
ãµã³ãã«ã³ã¼ã
ããã«ãµã³ãã«ã³ã¼ããããã¦ããã¾ãã