美文网首页
高德 CLLocationCoordinate2D 结构体变量添

高德 CLLocationCoordinate2D 结构体变量添

作者: 米开朗骑騾 | 来源:发表于2019-11-07 22:25 被阅读0次
    - (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location{
    //实时获取经纬度
      NSLog(@"location:{lat:%f; lon:%f; accuracy:%f}", location.coordinate.latitude, location.coordinate.longitude, location.horizontalAccuracy);
      
    //获取的经纬度
      CLLocationCoordinate2D cll ={location.coordinate.latitude,location.coordinate.longitude} ;
      
      CLLocation *towerLocation = [[CLLocation alloc] initWithLatitude:cll.latitude longitude:cll.longitude];
      
    //放到数组集合里
      [self.coordsArr addObject:towerLocation];
      
    //声明CLLocationCoordinate2D对象
      NSInteger count = [self.coordsArr count];
      CLLocationCoordinate2D Coords[count];
      
    //给CLLocationCoordinate2D添加收集的经纬度
      for (int i =0; i <count; i++) {
        
        Coords[i]=[[self.coordsArr objectAtIndex:i] coordinate];
      }
      
    //绘制你的路线
        MAPolyline *commonPolyline = [MAPolyline polylineWithCoordinates:Coords count:count];
        [_mapView addOverlay:commonPolyline];
    }
    

    相关文章

      网友评论

          本文标题:高德 CLLocationCoordinate2D 结构体变量添

          本文链接:https://www.haomeiwen.com/subject/pmhawftx.html