使用CLGeocoder转发地理编码示例 [英] Forward Geocode Example using CLGeocoder

查看:118
本文介绍了使用CLGeocoder转发地理编码示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关如何在Apple文档旁边使用正向地理编码的工作示例或指导的说明。那是非常通用的(我无法理解)

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)

请这太好了!也有人知道他们是否使用Google API来实现相同或自己的目标吗?

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

推荐答案

发现这个工作,虽然我如果其他人觉得它有用,我会在这里发布。

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

这篇关于使用CLGeocoder转发地理编码示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆