2013-03-13 46 views
0

我添加了MapView和和显示当前位置所需的条件,并且按钮功能从苹果文档中添加了此方法。ios6中的mapView中的路径追踪

- (IBAction)refreshMapMethod:(id)sender 

{

double latitude = 39.281516; 
double longitude =-76.580806; 


MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) addressDictionary:nil]; 
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark]; 
[mapItem setName:@"Name of your location"]; 
[mapItem openInMapsWithLaunchOptions:nil]; 

///// 
//////// 

CLLocation* fromLocation = mapItem.placemark.location; 

// Create a region centered on the starting point with a 10km span 

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(fromLocation.coordinate, 10000, 10000); 

// Open the item in Maps, specifying the map region to display. 

[MKMapItem openMapsWithItems:[NSArray arrayWithObject:mapItem] 
       launchOptions:[NSDictionary dictionaryWithObjectsAndKeys: 
           [NSValue valueWithMKCoordinate:region.center], MKLaunchOptionsMapCenterKey, 
           [NSValue valueWithMKCoordinateSpan:region.span], MKLaunchOptionsMapSpanKey, nil]]; 

}

按下按钮后,我得到新的观点与所有喜欢的地图视图添加注释,长按,跟踪路径的功能以及更多。如何这正在发生小功能

任何想法请求帮助。

回答

0

openInMapsWithLaunchOptions:openMapsWithItems:launchOptions:都将打开Apple Maps应用程序(并将您的应用程序置于后台)。可能这不是你想要的。