Forward Geocode Example using CLGeocoder

和自甴很熟 提交于 2019-12-19 03:54:33

问题


A directions to a working example or some guidance on how to use the forward geocoding beside the Apple Documentation. Thats pretty generic (i cant understand)

Please this would be great! Also does anyone know if they are using Google API to achieve the same or their own?


回答1:


Found this to work, though i will post it here if someone else finds it useful.

CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder geocodeAddressString:PlaceName.text completionHandler:^(NSArray *placemarks, NSError *error) {
        //Error checking

        CLPlacemark *placemark = [placemarks objectAtIndex:0];
        MKCoordinateRegion region;
        region.center.latitude = placemark.region.center.latitude;
        region.center.longitude = placemark.region.center.longitude;
        MKCoordinateSpan span;
        double radius = placemark.region.radius / 1000; // convert to km

        NSLog(@"Radius is %f", radius);
        span.latitudeDelta = radius / 112.0;

        region.span = span;

        [mapView setRegion:region animated:YES];
    }];


来源:https://stackoverflow.com/questions/9771221/forward-geocode-example-using-clgeocoder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!