2014-09-29 131 views
9

在iOS 8.0默认地图应用程序中,当点击POI点时,将获得详细信息,包括POI和地址的名称。有关poi点的详细信息MKMapview

我的问题是:

  1. 是否有可能做同样的,因为这使用的MKMapView或iOS本机代码?

  2. 如果没有,我怎么能得到的POI数据与地图比例尺(因为地图上显示的POI点依赖于区域和规模)。因此,我需要获取数据,以便根据此区域和比例了解哪个POI点显示。

回答

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"); 
        } 
    ]; 
    

如果您需要中心在区域地图你可以做到这一点,就像这样:

- (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]; 
} 

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

想了解更多关于MKMapViewClass(我推荐它)检查Apple Documentationthis beatiful example on how to manage POI with Apple Maps