【发布时间】:2013-07-29 11:06:08
【问题描述】:
我想在MKMapView 上加载地图。
基本上我想做的是,
我想在我的 MapView 中加载特定的 Venue。
我的数据库包含很多Venues,根据要求,我正在获取Venue,我想在我的mapView 中加载Venue。
例如:我从数据库中得到 Venue: @"100 Oxford Street, London, W1D 1LL, 020 7636 0933",然后我想在我的 mapView 中加载这个位置 p>
提前致谢。
编辑:
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
NSString *venue= @"100 Oxford Street, London, W1D 1LL, 020 7636 0933";
[geocoder geocodeAddressString:venue completionHandler:^(NSArray *placemarks, NSError *error)
{
if ([placemarks count] > 0)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
CLLocation *loc = placemark.location;
CLLocationCoordinate2D _venue = loc.coordinate;
NSLog(@"_venue:=%f",loc.coordinate);
MKPointAnnotation *venueAnnotation = [[MKPointAnnotation alloc]init];
[venueAnnotation setCoordinate:_venue];
[venueAnnotation setTitle:@"Venue"];
[MapVw addAnnotation:venueAnnotation];
}
}
];
【问题讨论】:
-
使用地理编码器从地址获取经纬度并向您的 MKMapView 添加注释
-
@property (weak, nonatomic) IBOutlet MKMapView *MapVw;我也连接了代理。
标签: iphone ios ipad google-maps mkmapview