时效库 TIMapboxGeocoder 0.2.0

TIMapboxGeocoder 0.2.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新版发布2015年9月

Benjamin Digeon 维护。



  • 出品者
  • Benjamin Digeon

要求

ios7 或更高

安装

TIMapboxGeocoder 可以通过 CocoaPods 获得。要安装它,只需在 Podfile 中添加以下行

pod "TIMapboxGeocoder"

用法

首先,导入此库

#import "TIMapboxGeocoder.h"

初始化

    TIMapboxGeocoder* geocoder = [[TIMapboxGeocoder alloc] initWithAccessToken:@"XXXX-XXXXX-XXXXX"];

您需要一个 Mapbox 访问令牌

地理编码

    TIMapboxGeocoder* geocoder = [[TIMapboxGeocoder alloc] initWithAccessToken:@"XXXX-XXXXX-XXXXX"];
    [geocoder geocodeAddressString:@"Paris" proximity:nil completionHandler:^(NSArray *results, NSError *error) {
        if (error) {
            // Handle error
        }
        TIPlacemark* placemark = results.firstObject;
        NSLog(@"First placemark name : %@", placemark.name);
    }]; 

Nb : proximity 可以是 nil 或靠近搜索区域的 CLLocation 对象

逆向地理编码

    CLLocation* location = [[CLLocation alloc] initWithLatitude:0.0 longitude:0.0];
    [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *results, NSError *error) {
        if (error) {
            // Handle error
        }
        TIPlacemark* placemark = results.firstObject;
        NSLog(@"First placemark name : %@", placemark.name);
}];

TIPlacemark 对象

@interface TIPlacemark : NSObject

- (CLLocation*) location;
- (NSString*) name;

@end

作者

Benjamin Digeon,TingsLabs (http://www.tingslabs.com),[email protected]

致谢

此 Objective-C 实现受到原始 MapBox 地理编码实现灵感的启发。

在此处查看原始 Swift 实现: https://github.com/mapbox/MapboxGeocoder.swift

许可证

TIMapboxGeocoder 可在 MIT 许可下使用。有关更多信息,请参阅 LICENSE 文件。