我添加了 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]];
}
按下按钮后,我将获得具有所有功能的新视图,例如通过长按在地图视图上添加注释、跟踪路径等等。这是如何通过小功能发生的
任何想法请帮忙。