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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

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

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

簡(jiǎn)介

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

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

面向的讀者

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

功能介紹與體驗(yàn)

抱歉,您的瀏覽器不支持video標(biāo)簽

抱歉,您的瀏覽器不支持video標(biāo)簽

抱歉,您的瀏覽器不支持video標(biāo)簽基礎(chǔ)定位

- (void)configLocationManager

{

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

[self.locationManager setDelegate:self];

[self.locationManager setPausesLocationUpdatesAutomatically:NO];

[self.locationManager setAllowsBackgroundLocationUpdates:YES];

}

- (void)startSerialLocation

{

//開(kāi)始定位

[self.locationManager startUpdatingLocation];

}

- (void)stopSerialLocation

{

//停止定位

[self.locationManager stopUpdatingLocation];

}

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

{

//定位錯(cuò)誤

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(@"開(kāi)始監(jiān)聽(tīng)地理圍欄:%@", region);

}

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

{

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

}

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

{

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

}

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

{

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

}

賬號(hào)與Key的申請(qǐng)

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

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

第二步,去控制臺(tái)創(chuàng)建應(yīng)用;

第三步,獲取Key。

具體步驟可參看下圖

兼容性

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

給開(kāi)發(fā)者的建議

高德開(kāi)放平臺(tái)提供的地圖API/SDK,任何非盈利性網(wǎng)站/應(yīng)用均可免費(fèi)使用 。請(qǐng)參閱《高德地圖 API 使用條款》獲得詳細(xì)信息。

總結(jié)

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

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