首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏算法微时光

    位置定位(LocationManager)

    image.png 目录 LocationManager LocationManager是Android 提供的Location 服务,来获得当前的位置信息和卫星信息。 LocationManager lm; lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 定位服务的提供一般有 =(LocationManager)getSystemService(Context.LOCATION_SERVICE); //获取所有可用的位置提供器 provider =LocationManager.GPS_PROVIDER; Location location=locationManager.getLastKnownLocation(provider (provider, 1000, 1, locationListener); } //LocationListener 用于当位置信息变化时由 locationManager 调用

    3K30发布于 2020-06-11
  • 来自专栏全栈程序员必看

    LocationManager的简单使用

    LocationManager 在Android中可以根据LocationManager来获取设备所在的地理信息 根据需求可以将定位的代码移动到所需的地方或者可以稍加改动获取城市的信息 MainActivity locationManager; private String locationProvider; @Override protected void onCreate(Bundle 引用 locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // if (providers.contains(LocationManager.GPS_PROVIDER)) { locationProvider = LocationManager.GPS_PROVIDER ; } else if (providers.contains(LocationManager.NETWORK_PROVIDER)) { locationProvider

    1.3K50编辑于 2022-07-22
  • 来自专栏小蠢驴iOS专题

    使用Category+runtime简单解决高德地图定位问题

    10s _locationManager.reGeocodeTimeout = 10; // 带逆地理(返回坐标和地址信息)。 ;,然后用成员变量 _locationManager 进行定位操作 如果有两个(或多个)控制器可能用到定位功能,岂不是每个地方都要写这么多代码? orangeColor]; //这里不用_locationManager,不声明locationManager属性,new一个新的AMapLocationManager AMapLocationManager *locationManager = [AMapLocationManager manager]; [locationManager requestLocationWithReGeocode 属性的问题 使用runtime的关联对象,为分类的locationManager属性赋值(set && get方法) locationManager的创建,也可以使用分类,使用AMapLocationManager

    1.4K50发布于 2018-05-24
  • 来自专栏移动开发面面观

    iOS学习笔记——LBS

    #import "LocationManager.h" @implementation LocationManager CLLocationManager *_locationManager;// _locationManager.delegate = self; #pragma mark - 定位失败 -(void)locationManager:(CLLocationManager *)manager requestWhenInUseAuthorization requestAlwaysAuthorization 最终,我们在LocationManager.m中的代码是: #import "LocationManager.h " @implementation LocationManager CLLocationManager *_locationManager;//定位服务 NSString *_currentCity 中调用了 var locationManager : LocationManager = LocationManager() ...

    2.2K30发布于 2018-07-03
  • 来自专栏大宇笔记

    swift 定位封装一句话使用

    闭包返回信息:定位Location+反编译地址信息+error git地址:https://github.com/RainManGO/LocationManager 使用代码: LocationManager.shareManager.creatLocationManager "没有错误")") } 封装代码: // // LocationManager.swift // ZYLocationManager // // Created by Nvr on All rights reserved. // import UIKit import CoreLocation class LocationManager: NSObject { ->() //MARK:-属性 ///单例,唯一调用方法 static let shareManager:LocationManager = LocationManager startUpdatingLocation() print("定位开始") } } } extension LocationManager:

    1.6K20发布于 2019-01-15
  • 来自专栏Android小知识

    Android获取经纬度

    对象 locationManager = (LocationManager) getSystemService(serviceName); 第二步 指定LocationManager的定位方法 ,然后调用 LocationManager.getLastKnowLocation()方法获取当前位置 代码如下 // 指定LocationManager的定位方法 String provider = LocationManager.GPS_PROVIDER 首先我们要调用requestLocationUpdates,代码如下 locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 3000, 0, mLocationListener01); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER = null) { locationManager.removeUpdates(mLocationListener01); locationManager

    3.6K30发布于 2019-08-14
  • 来自专栏全栈程序员必看

    微信模拟位置想在哪就在哪(GPS欺骗)

    = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); LocationProvider provider = locationManager.getProvider(mMockProviderName); if (provider ! = null) { locationManager.addTestProvider( provider.getName() (mMockProviderName, true); //新 locationManager.setTestProviderStatus(mMockProviderName (LocationManager.GPS_PROVIDER); } catch (Exception ex) { // 若未成功addTestProvider

    3.8K20编辑于 2022-08-12
  • 来自专栏日常技术分享

    iOS 后台持续定位

    //初始化实例 _locationManager = [[BMKLocationManager alloc] init]; //设置delegate _locationManager.delegate _locationManager.distanceFilter = kCLDistanceFilterNone; //设置预期精度参数 _locationManager.desiredAccuracy = YES; //设置位置获取超时时间 _locationManager.locationTimeout = 10; //设置获取地址信息超时时间 _locationManager.reGeocodeTimeout 代码如下: [self.locationManager startUpdatingLocation]; 如果需要持续定位返回地址信息(需要联网),请设置如下: [self.locationManager self.locationManager) { self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate

    2.2K30发布于 2018-12-19
  • 来自专栏MapleYe

    【iOS】RxSwift官方Example3--地理位置监听

    { let locationManager: CLLocationManager = object as! , toObject object: AnyObject) { let locationManager: CLLocationManager = object as! CLLocationManagerDelegate) } else { locationManager.delegate = nil } = CLLocationManager.authorizationStatus() guard let locationManager = locationManager else { () locationManager.startUpdatingLocation() } } 这里的service层就是将之前扩展的LocationManager再次封装。

    1.4K20发布于 2020-03-31
  • 来自专栏joealzhou

    iOS区域监控(地理围栏)

    一、导入框架 import CoreLocation 二、初始化CLLocationManager locationManager = CLLocationManager() locationManager.delegate = self //必须满足始终允许地理位置访问 locationManager.requestAlwaysAuthorization() locationManager.pausesLocationUpdatesAutomatically = false if #available(iOS 9.0, *) { locationManager.allowsBackgroundLocationUpdates = true } else { radius = self.locationManager.maximumRegionMonitoringDistance } (for: region) locationManager.requestState(for: region) } }

    1.9K21发布于 2019-08-23
  • 来自专栏学海无涯

    iOS开发之集成高德地图(一)

    = [[AMapLocationManager alloc]init]; // 设置代理对象 self.locationManager.delegate = self; // ; } //开启持续定位 [self.locationManager startUpdatingLocation]; } #pragma mark - 持续定位 - (void)alwaysLoaction{ //初始化定位管理器 self.locationManager = [[AMapLocationManager alloc]init ]; // 设置代理对象 self.locationManager.delegate = self; // 设置反地理编码 self.locationManager.locatingWithReGeocode = YES; //开启持续定位 [self.locationManager startUpdatingLocation]; } #pragma mark - 单次定位 -

    2K60发布于 2018-05-03
  • 来自专栏全栈程序员必看

    CLLocation定位

    () locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.distanceFilter = 1000 locationManager.requestAlwaysAuthorization() locationManager.requestWhenInUseAuthorization () locationManager.delegate = self locationManager.startUpdatingLocation() } () } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error (“空”, “空”, “空”) } } } func locationManager(_ manager: CLLocationManager,

    84520编辑于 2022-09-17
  • 来自专栏学海无涯

    iOS开发之定位

    通过设置distanceFilter可以实现当位置改变超出一定范围时LocationManager才调用相应的代理方法。这样可以达到省电的目的。 locationManager.distanceFilter = 300 //精度 比如为10 就会尽量达到10米以内的精度 locationManager.desiredAccuracy (打开后台定位的开关) //允许后台定位 locationManager.allowsBackgroundLocationUpdates = true locationManager.requestWhenInUseAuthorization () //第二种:能后台定位并且不会出现大蓝条 //locationManager.requestAlwaysAuthorization() } extension ViewController : CLLocationManagerDelegate{ //定位成功 func locationManager(_

    1.9K10发布于 2019-03-21
  • 来自专栏sktj

    IOS 定位CoreLocation

    import CoreLocation 2 class ViewController:UIViewController,CLLocationManagerDelegate 3 var locationManager = CLLocationManager() 10 locationManager.delegate = self 11 locationManager.desiredAccuracy = kCLLocationAccuracyBest 12 locationManager.distanceFilter = 1000.0 13 14 label = UILabel(frame:CGRect(x:20, y:80, width: () 21 } 22 } 23 func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: 27 break; 28 default: 29 manager.startUpdatingLocation() 30 break; 31 } 32 } 33 func locationManager

    52820发布于 2019-07-10
  • 来自专栏iOSDevLog

    ARKit和CoreLocation:第三部分

    = CLLocationManager() guard let locationManager = locationManager else { return } () locationManager.startUpdatingHeading() lastLocation = locationManager.location locationManager.headingFilter = kCLHeadingFilterNone locationManager.pausesLocationUpdatesAutomatically locationManager?. startUpdatingLocation() } func stopUpdatingLocation() { locationManager?.

    1.4K20发布于 2018-09-20
  • 来自专栏云计算linux

    GPS用户定位

    就像Android为电话管理支持提供了TelephonyManager类、为音频管理支持提供了AudioManager类一样,Android为GPS提供了LocationManager类,通过LocationManager ,如下代码所示: LocationManager lm = getSystemService(Context.LOCATION_SERVICE); 一旦在程序中获得了LocationManager对象之后 ,接下来即可调用LocationManager的方法来获取GPS定位的相关服务和对象。 Ø passive:由LocationManager.PASSIVE_PROVIDER常量表示。 LocationManager类提供了访问定位服务的功能,该类提供了如下常用的方法。

    1.3K10编辑于 2024-12-17
  • 来自专栏码客

    iOS地图开发1-定位(swift)

    :CLLocationManager = CLLocationManager() let geocoder:CLGeocoder = CLGeocoder(); (3)初始化设置 locationManager.delegate = self //精确到10米,距离过滤器,定义了设备移动后获得位置信息的最小距离 locationManager.desiredAccuracy = kCLLocationAccuracyBest //十米定位一次 locationManager.distanceFilter=10.0; if((UIDevice.currentDevice().systemVersion as NSString ).doubleValue>8.0){ locationManager.requestAlwaysAuthorization() } (4)实现代理的两个方法 func locationManager CLLocation if (location.horizontalAccuracy > 0) { self.locationManager.stopUpdatingLocation

    1.9K10发布于 2019-10-22
  • 来自专栏iOSer成长记录

    iOS-CoreLocation框架的定位和逆地址解析详解

    = 10 // 请求定位权限(注意这个方法只有iOS8以上才有,8之前是不用请求权限的) self.locationManager.requestAlwaysAuthorization () } 3.开始定位 func startUpdatingLocation() { // 设置代理 self.locationManager.delegate = self // 开始定位(没有网络,也可以定位) self.locationManager.startUpdatingLocation() // 设置定位30s超时 self.perform ), object: nil) } 5.停止定位 func stopUpdatingLocation(){ // 置空代理 self.locationManager.delegate = nil // 停止定位 self.locationManager.stopUpdatingLocation() } 三、CLLocation对象详解 open var coordinate

    1.6K20发布于 2018-06-29
  • 来自专栏爱打音游的大A

    安卓虚拟定位

    = Java.use("android.location.LocationManager") var Location = Java.use("android.location.Location ") LocationManager.getLastLocation.implementation = function(){ console.log("getLastLocation $new(LocationManager.GPS_PROVIDER.value) location.setLatitude(Latitude) location.setLongitude $new(LocationManager.GPS_PROVIDER.value) location.setLatitude(Latitude) location.setLongitude $new() array.add("gps") return array } LocationManager.getProviders.overload

    3.5K30编辑于 2023-02-14
  • 来自专栏云原生布道专栏

    【IOS开发基础系列】地图开发专题

    If locationManager:didUpdateLocations: is  *   implemented, this method will not be called.  */ - (void Ifimplemented, updates will  *   not be delivered to locationManager:didUpdateToLocation:fromLocation : (CLLocationManager *)manager didVisit: (CLVisit*)visit; 1.2 使用示例 1.2.1 locationManager初始化 self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; self.locationManager.distanceFilter = 1000.0f; [self.locationManager startUpdatingLocation

    1.1K30编辑于 2023-10-16
领券