Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 是否可以仅根据物理地址向映射套件添加管脚_Ios_Objective C_Mkmapview - Fatal编程技术网

Ios 是否可以仅根据物理地址向映射套件添加管脚

Ios 是否可以仅根据物理地址向映射套件添加管脚,ios,objective-c,mkmapview,Ios,Objective C,Mkmapview,是否可以仅根据物理地址将管脚添加到映射套件中,或者是否有一种方法可以根据物理地址获取long和lat是的,您可以从地址获取lat long。 请参阅以下答案: 基本上是这样的: NSString *location = @"some address, state, and zip"; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location

是否可以仅根据物理地址将管脚添加到映射套件中,或者是否有一种方法可以根据物理地址获取long和lat是的,您可以从地址获取lat long。 请参阅以下答案:

基本上是这样的:

NSString *location = @"some address, state, and zip";
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];
                     }
                 }
             ];