当前位置:首页 > 资讯 > 正文

ios用高德地图定位到某个位置 苹果手机高德地图定位苹果手机怎么看经纬度「ios用高德地图定位到某个位置 苹果手机高德地图定位」


一、定位服务介绍

iOS中有三个定位服务组件:

(1)Wifi定位,通过查询一个Wifi路由器的地理位置的信息。比较省电,iPod touch和iPad也可以采用。

(2)蜂窝基站定位,通过移动运用商基站定位。也适合有3G版本的iPod touch和iPad

(3)GPS卫星定位,通过3-4颗GPS定位位置定位,最为准确,但是耗电量大,不能遮挡。

二、项目引用库介绍

(1)CoreLocation.framework 是开发定位服务应用程序的框架

(2)MapKit.framework 是开发地图应用的框架

ios用高德地图定位到某个位置 苹果手机高德地图定位_User

三、位置模拟

模拟器定位有6个选项:

ios用高德地图定位到某个位置 苹果手机高德地图定位_ios用高德地图定位到某个位置_02

(1)None

(2)Custom Location

(3)Apple

(4)City Bicycle Ride

(5)City Run

(6)Freeway Drive

单机"Custom Location"选项,会弹出如下对话框,要求设置待模拟的经纬度

ios用高德地图定位到某个位置 苹果手机高德地图定位_#pragma_03

设置后,会触发 “-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations;” 函数,打印如下:

ios用高德地图定位到某个位置 苹果手机高德地图定位_ios用高德地图定位到某个位置_04

注意:如果设置的不是 “Custom Location”,其他的选项我试了一遍,都会报错

触发 “-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error” 函数,打印如下

ios用高德地图定位到某个位置 苹果手机高德地图定位_User_05

四、项目实战

(1)ViewController.h

(2)ViewController.m

(3)CustomAnnotation.h

(4)CustomAnnotation.m

五、运行截图

ios用高德地图定位到某个位置 苹果手机高德地图定位_ios用高德地图定位到某个位置_06


最新文章