0
我以前從未使用過的地圖視圖,而我下面this教程MapView類顯示引腳位置,然後消失
在最後,我的模擬器顯示了點它應該是,在路上它應該位於的位置,但是會立即變爲藍色屏幕。
藍屏仍然在谷歌地圖(它顯示谷歌標誌在底部),但它不再是我試圖展示。
下面是我的一些代碼:
- (void)viewDidLoad
{
HandbookAppDelegate *delegate = (HandbookAppDelegate *)[[UIApplication sharedApplication] delegate];
Rule *thisRule = [delegate.rules objectAtIndex:index.row];
self.title = thisRule.ruleNumber;
// Set some coordinates for our position (Buckingham Palace!)
CLLocationCoordinate2D location;
location.latitude = (double) 51.501468;
location.longitude = (double) -0.141596;
// Add the annotation to our map view
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self.map addAnnotation:newAnnotation];
[newAnnotation release];
}
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];
}