zoukankan      html  css  js  c++  java
  • 让百度地图只再应用程序启动时,仅取一次用户坐标信息

    方法: 再百度地图的委托方法   - (void)mapView:(BMKMapView *)mapView didUpdateUserLocation:(BMKUserLocation *)userLocation   中设置:

    [mapView setShowsUserLocation:NO];

    例子代码:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        configData = [NSUserDefaults standardUserDefaults];     //初始化对象
    
        //启动BMKMapManager  (加载百度地图前,必须先启动BMKMapManager)
        _mapManager = [[BMKMapManager alloc]init];
        BOOL ret = [_mapManager start:@"2772BD5CAFF652491F65707D6D5E9ABEBF3639CC"generalDelegate:self];
        if (!ret) {
            NSLog(@"manager start failed!");
        }
        //创建一张百度地图
        _mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0,600, 5,5)];
        [_mapView setShowsUserLocation:YES];      //此处设置为YES
        _mapView.delegate = self;
        [self.view addSubview:_mapView];
        
    }
    - (void)mapView:(BMKMapView *)mapView didUpdateUserLocation:(BMKUserLocation *)userLocation
    {
        if (userLocation != nil) {
            [configData setObject:[NSString stringWithFormat:@"%f",userLocation.location.coordinate.latitude] forKey:@"lat"];
            [configData setObject:[NSString stringWithFormat:@"%f",userLocation.location.coordinate.longitude] forKey:@"lng"];
            NSLog(@"程序初始化获取的经纬度=%@,%@",[configData objectForKey:@"lng"],[configData objectForKey:@"lat"]);
        }
        //可以保证用户的坐标只取一次
        [mapView setShowsUserLocation:NO];   //此处设置为NO
    }

    此方法可以在一定程度上提高应用程序的运行速度并且减少用户的耗电量。

  • 相关阅读:
    函数集
    2019.1.7
    第九次团队作业-测试报告与用户使用手册
    α版本升升备忘录下载链接
    系统设计和任务分配(个人)
    团队作业说明
    备忘录-团队选题报告
    需求分析与原型设计---升升备忘录
    项目——四则运算器
    Hello Django
  • 原文地址:https://www.cnblogs.com/ygm900/p/3099555.html
Copyright © 2011-2022 走看看