我想在plist中添加纬度和经度,并希望在地图视图中显示位置。 我无法在plist中加载纬度和经度。
NSString *path = [[NSBundle mainBundle] pathForResource:@"map" ofType:@"plist"];
NSArray *anns = [NSArray arrayWithContentsOfFile:path];
NSLog(@"anns=%@",anns);
for(NSMutableDictionary *note in anns) {
float realLatitude = [[note objectForKey:@"latitude"] floatValue];
float realLongitude = [[note objectForKey:@"logitude"] floatValue];
WHLocationAnnotation* myAnnotation = [[WHLocationAnnotation alloc] init];
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = realLatitude;
theCoordinate.longitude = realLongitude;
NSLog(@"...abc...%f",[[note objectForKey:@"latitude"] floatValue]);
myAnnotation.title = [note objectForKey:@"Title"];
myAnnotation.subtitle = [note objectForKey:@"subtitle"];
[mapViewForAnnotation setDelegate:self];
[mapViewForAnnotation addAnnotation:myAnnotation];
}
}
我在viewdidload中完成了这个。我使用nslog获取经度,但mapview上的位置不正确。