【发布时间】:2016-02-09 13:14:13
【问题描述】:
我正在使用以下代码将数组 (responseObject) 中的地址显示为我的地图视图上的注释。它可以工作,并且该引脚已从我的位置字符串中成功删除,但是它仅显示添加到数组中的最新地址的引脚。如何更改我的代码,以便它在地图上显示我数组中所有地址的图钉,而不仅仅是最近的地址?抱歉,如果这是一个新手问题。谢谢!
viewcontroller.m
NSMutableDictionary *viewParams = [NSMutableDictionary new];
[viewParams setValue:@"u000" forKey:@"view_name"];
[DIOSView viewGet:viewParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.addressData = [responseObject mutableCopy];
NSString *location = self.addressData[0][@"address"];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray* placemarks, NSError* error){
if (placemarks && placemarks.count > 0) {
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];
MKCoordinateRegion region = self.mapView.region;
// region.center = placemark.region.center;
region.span.longitudeDelta /= 8.0;
region.span.latitudeDelta /= 8.0;
[self.mapView setRegion:region animated:YES];
[self.mapView addAnnotation:placemark];
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = placemark.coordinate;
point.title = self.addressData[0][@"users_name"];
point.subtitle = self.addressData[0][@"userbio"];
[self.mapView addAnnotation:point];
【问题讨论】:
标签: ios objective-c mkmapview