ios6中mapView中的路径跟踪

时间:2013-03-13 10:17:37

标签: iphone path gps mapkit tracing

我添加了MapView和显示当前位置所需的条件,并且通过按钮功能从Apple文档中添加了此方法。

- (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]];

}

按下按钮后,我将获得所有功能的新视图,例如在地图视图上添加注释,长按,跟踪路径等等。显示小功能的情况

任何想法请求帮助。

1 个答案:

答案 0 :(得分:0)

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