关于MKMapview中poi点的详细信息

Hua*_*jie 9 mkmapview ios point-of-interest

在iOS 8.0默认地图应用程序中,当您点击POI点时,您将获得详细信息,包括POI名称和地址.

我的问题是:

  1. 是否可以使用MKMapView或IOS本机代码执行相同操作?

  2. 如果没有,我如何获得具有地图比例的POI数据(因为地图上显示的POI点依赖于区域和比例).因此,我需要获取数据以了解哪个POI点基于此区域和比例显示.

Mas*_*eni 4

要获取包括 POI 地址在内的详细信息,我认为您可以分两步进行:

  1. 获取您的 POI 坐标

  2. 转换它们以获取地址信息;看看这个美丽的例子:

    CLGeocoder *ceo = [[CLGeocoder alloc]init];
    CLLocation *loc = [[CLLocation alloc]initWithLatitude:32.00 longitude:21.322]; //insert your coordinates
    
    [ceo reverseGeocodeLocation:loc
          completionHandler:^(NSArray *placemarks, NSError *error) {
             CLPlacemark *placemark = [placemarks objectAtIndex:0];
             NSLog(@"placemark %@",placemark);
             //String to hold address
             NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
             NSLog(@"addressDictionary %@", placemark.addressDictionary);
    
             NSLog(@"placemark %@",placemark.region);
             NSLog(@"placemark %@",placemark.country);  // Give Country Name
             NSLog(@"placemark %@",placemark.locality); // Extract the city name
             NSLog(@"location %@",placemark.name);
             NSLog(@"location %@",placemark.ocean);
             NSLog(@"location %@",placemark.postalCode);
             NSLog(@"location %@",placemark.subLocality);
    
             NSLog(@"location %@",placemark.location);
             //Print the location to console
             NSLog(@"I am currently at %@",locatedAt);
         }
         else {
             NSLog(@"Could not locate");
         }
    ];
    
    Run Code Online (Sandbox Code Playgroud)

如果您需要以地图的某个区域为中心,您可以这样做:

- (void)gotoLocation
{
    MKCoordinateRegion newRegion;

    newRegion.center.latitude = NY_LATITUDE;
    newRegion.center.longitude = NY_LONGTITUDE;

    newRegion.span.latitudeDelta = 0.5f;
    newRegion.span.longitudeDelta = 0.5f;

    [self.myMapView setRegion:newRegion animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

我希望这些代码示例可以帮助您:)

要了解有关MKMapViewClass的更多信息(我推荐它),请查看Apple 文档有关如何使用 Apple 地图管理 POI 的精彩示例