小编use*_*517的帖子

使用iOS中的Geocoder类,根据地址获取纬度和经度

我根据经度和纬度值获得了当前位置,然后我还使用Annotation在Google地图上获得了多个位置.现在我想根据地址(即街道,城市和县)获取经度和纬度值.需要一些指导如何实现.

直到现在,这是我尝试过的: -

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize streetField = _streetField, cityField = _cityField, countryField = _countryField, fetchCoordinatesButton = _fetchCoordinatesButton, nameLabel = _nameLabel, coordinatesLabel = _coordinatesLabel;
@synthesize geocoder = _geocoder;


- (void)viewDidLoad
{

    [super viewDidLoad];
    _streetField.delegate=self;
    _cityField.delegate=self;
    _countryField.delegate=self;

    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)fetchCoordinates:(id)sender {
    NSLog(@"Fetch Coordinates");
    if (!self.geocoder) {
          NSLog(@"Geocdoing");
        self.geocoder = [[CLGeocoder alloc] init];
    }

    NSString *address = [NSString stringWithFormat:@"%@ %@ %@", self.streetField.text, self.cityField.text, …
Run Code Online (Sandbox Code Playgroud)

iphone geocoding objective-c ios

11
推荐指数
2
解决办法
3万
查看次数

标签 统计

geocoding ×1

ios ×1

iphone ×1

objective-c ×1