2016-01-13 36 views
1

我想用修改的標記和細節打開我的經度和緯度值。因此,我需要檢查是否需要打開Goog​​le地圖應用,否則我將導航到蘋果地圖。使用地圖和標記針打開位置

在這裏我不能添加自定義引腳與下面的代碼,

 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"maps.apple.com/?z=12&q=%f,%f",[latitude floatValue],[longitude floatValue]]]; 

     if (![[UIApplication sharedApplication] canOpenURL:url]) { 
      NSLog(@"Google Maps app is not installed"); 
      //left as an exercise for the reader: open the Google Maps mobile website instead! 
      MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:rdOfficeLocation addressDictionary:nil]; 

      MKMapItem *item = [[MKMapItem alloc] initWithPlacemark:placemark]; 

      item.name = [NSString stringWithFormat:@"%@",[[mDataArray1 objectAtIndex:indexPath.row] valueForKey:@"NAME"]]; 
      item.phoneNumber = [NSString stringWithFormat:@"%@",[[mDataArray1 objectAtIndex:indexPath.row] valueForKey:@"DESTINATION"]]; 
      [item openInMapsWithLaunchOptions:nil]; 

     } else { 

      [[UIApplication sharedApplication] openURL:url]; 

     } 

所以,請幫我添加自定義引腳值兩個蘋果和谷歌地圖。

回答

0

你可以看看如何在官方文檔中添加custom marker。但是,這隻適用於Google地圖,而不適用於Apple地圖(在這種情況下,您需要爲其提供不同的庫)