ios 百度地图轨迹回放一点心得
来源:互联网 发布:虎牙 斗鱼 知乎 编辑:程序博客网 时间:2024/04/30 01:27
由于项目需要,需要通过百度地图sdk实现轨迹回放。
使用一个非常简单的办法来实现轨迹回放。
话不多说,出来吧,代码君。
1,使用的是BMKPointAnnotation。
@interface TrackMapViewController (){ BMKPointAnnotation * pointAnnotation;}
2,通过服务器回传值,绘制行驶路径轨迹
CLLocationCoordinate2D start_coor[steparray.count]; for (int i = 0; i<steparray.count;i++) { start_coor[i].latitude = [[[steparray objectAtIndex:i]objectForKey:@"lat"] floatValue]; start_coor[i].longitude = [[[steparray objectAtIndex:i]objectForKey:@"lon"] floatValue]; } [mapView setCenterCoordinate:start_coor[0]]; BMKPolyline * polyline = [BMKPolyline polylineWithCoordinates:start_coor count:steparray.count]; [mapView addOverlay:polyline]; pointAnnotation = [[BMKPointAnnotation alloc]init]; pointAnnotation.coordinate = start_coor[0]; pointAnnotation.title = @"起点"; [mapView addAnnotation:pointAnnotation];
3,使用NSTimer,间隔一定时间刷新point位置,达到播放轨迹效果
timer =[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(playTrack) userInfo:nil repeats:YES];
4,刷新point
#pragma mark - 动画-(void)playTrack{ if (timeCount<steparray.count) { CLLocationCoordinate2D start_coor; start_coor.latitude = [[[steparray objectAtIndex:timeCount]objectForKey:@"lat"] floatValue]; start_coor.longitude = [[[steparray objectAtIndex:timeCount]objectForKey:@"lon"] floatValue]; timeCount = timeCount++; pointAnnotation.title = @"轨迹"; pointAnnotation.coordinate = start_coor; [mapView setCenterCoordinate:start_coor]; } else { [timer invalidate]; [[[UIAlertView alloc]initWithTitle:@"提示" message:@"播放结束" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil]show]; } }
5,有兴趣可以在此基础上实现暂停,2倍速,等功能。
0 0
- ios 百度地图轨迹回放一点心得
- 轨迹回放 百度地图
- 百度地图 - 轨迹回放
- android 百度地图轨迹回放
- 百度地图轨迹回放代码
- Android百度地图轨迹回放
- 使用百度地图API实现轨迹回放
- 使用百度地图API实现轨迹回放
- 百度地图API四:实现轨迹动态回放功能
- 百度地图——显示小车轨迹动画回放
- 高德地图轨迹回放
- iOS 百度地图 轨迹记录 道路贴合
- iOS 百度地图运动轨迹的角度
- 百度地图开发 (JQUERY 地图找房)电子栅栏,轨迹回放开发
- 最近使用百度地图的一点心得
- 安卓关于在百度地图上实现轨迹回放的处理
- 百度地图轨迹回放 快进 后退 停止 播放 暂停 的实现
- 百度地图进行车辆轨迹回放开发时碰到的问题
- PAT_B_循环-22. 输出闰年(15)
- getCurrentSession创建
- AC自动机
- 右键删除svn配置
- java的调用代码
- ios 百度地图轨迹回放一点心得
- HDU 3652 B-number
- C#读取“我的文档”等特殊系统路径及环境变量
- PAT_B_循环-21. 求交错序列前N项和(15)
- java方法
- Chapter 4 文件和目录
- 2048,成功和我
- DataValueField和DataTextField的区别及使用
- 佳域G3移植优米X1乐蛙ROM稳定版 卡刷包