日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ios 持续获取定位 高德地图_概述-iOS 定位SDK | 高德地图API

發(fā)布時間:2024/9/19 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios 持续获取定位 高德地图_概述-iOS 定位SDK | 高德地图API 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

簡介

高德 iOS 定位 SDK 提供了不依賴于地圖定位的定位功能,開發(fā)者可以無地圖顯示的場景中便捷地為應用程序添加定位功能。

iOS定位SDK提供了單次定位、連續(xù)定位、逆地理信息、地理圍欄等功能。

面向的讀者

高德地圖定位 SDK 是提供給具有一定 iOS 編程經(jīng)驗,了解面向?qū)ο缶幊谈拍畹淖x者使用的 iOS 移動端 SDK。

功能介紹與體驗

抱歉,您的瀏覽器不支持video標簽

抱歉,您的瀏覽器不支持video標簽

抱歉,您的瀏覽器不支持video標簽基礎定位

- (void)configLocationManager

{

self.locationManager = [[AMapLocationManager alloc] init];

[self.locationManager setDelegate:self];

[self.locationManager setPausesLocationUpdatesAutomatically:NO];

[self.locationManager setAllowsBackgroundLocationUpdates:YES];

}

- (void)startSerialLocation

{

//開始定位

[self.locationManager startUpdatingLocation];

}

- (void)stopSerialLocation

{

//停止定位

[self.locationManager stopUpdatingLocation];

}

- (void)amapLocationManager:(AMapLocationManager *)manager didFailWithError:(NSError *)error

{

//定位錯誤

NSLog(@"%s, amapLocationManager = %@, error = %@", __func__, [manager class], error);

}

- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location

{

//定位結(jié)果

NSLog(@"location:{lat:%f; lon:%f; accuracy:%f}", location.coordinate.latitude, location.coordinate.longitude, location.horizontalAccuracy);

}

逆地理編碼

- (void)configLocationManager

{

self.locationManager = [[AMapLocationManager alloc] init];

[self.locationManager setDelegate:self];

[self.locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];

[self.locationManager setLocationTimeout:6];

[self.locationManager setReGeocodeTimeout:3];

}

- (void)locateAction

{

//帶逆地理的單次定位

[self.locationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {

if (error)

{

NSLog(@"locError:{%ld - %@};", (long)error.code, error.localizedDescription);

if (error.code == AMapLocationErrorLocateFailed)

{

return;

}

}

//定位信息

NSLog(@"location:%@", location);

//逆地理信息

if (regeocode)

{

NSLog(@"reGeocode:%@", regeocode);

}

}];

}

地理圍欄

- (void)configLocationManager

{

self.locationManager = [[AMapLocationManager alloc] init];

[self.locationManager setDelegate:self];

[self.locationManager setPausesLocationUpdatesAutomatically:NO];

[self.locationManager setAllowsBackgroundLocationUpdates:YES];

}

- (void)addCircleReionForCoordinate:(CLLocationCoordinate2D)coordinate

{

int radius = 250;

//創(chuàng)建circleRegion

AMapLocationCircleRegion *cirRegion = [[AMapLocationCircleRegion alloc] initWithCenter:coordinate

radius:radius

identifier:@"circleRegion"];

//添加地理圍欄

[self.locationManager startMonitoringForRegion:cirRegion];

//保存地理圍欄

[self.regions addObject:cirRegion];

//添加Overlay

MACircle *circle = [MACircle circleWithCenterCoordinate:coordinate radius:radius];

[self.mapView addOverlay:circle];

[self.mapView setVisibleMapRect:circle.boundingMapRect];

}

- (void)amapLocationManager:(AMapLocationManager *)manager didStartMonitoringForRegion:(AMapLocationRegion *)region

{

NSLog(@"開始監(jiān)聽地理圍欄:%@", region);

}

- (void)amapLocationManager:(AMapLocationManager *)manager monitoringDidFailForRegion:(AMapLocationRegion *)region withError:(NSError *)error

{

NSLog(@"監(jiān)聽地理圍欄失敗:%@", error.localizedDescription);

}

- (void)amapLocationManager:(AMapLocationManager *)manager didEnterRegion:(AMapLocationRegion *)region

{

NSLog(@"進入地理圍欄:%@", region);

}

- (void)amapLocationManager:(AMapLocationManager *)manager didExitRegion:(AMapLocationRegion *)region

{

NSLog(@"退出地理圍欄:%@", region);

}

賬號與Key的申請

注冊成為高德開發(fā)者需要分三步:

第一步,注冊高德開發(fā)者;

第二步,去控制臺創(chuàng)建應用;

第三步,獲取Key。

具體步驟可參看下圖

兼容性

高德地圖 iOS 定位 SDK V2.2.0 之前的版本兼容 iOS 6.0 系統(tǒng),從 V2.2.0 版本以后從 iOS 7.0 系統(tǒng)開始支持。SDK 內(nèi)部網(wǎng)絡訪問全部應用域名訪問,不涉及 ipv4 和 ipv6 的問題。

給開發(fā)者的建議

高德開放平臺提供的地圖API/SDK,任何非盈利性網(wǎng)站/應用均可免費使用 。請參閱《高德地圖 API 使用條款》獲得詳細信息。

總結(jié)

以上是生活随笔為你收集整理的ios 持续获取定位 高德地图_概述-iOS 定位SDK | 高德地图API的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。