百度地图 绘制轨迹绘制轨迹和地图大小级别有没有关系

在百度地图上绘制运动轨迹图及相关事件处理
《Android系统定制和源码开发以及源码编译》
作者原文序:为了把Android系统源码定制和编译的课程讲完,从准备到录制完所有的视频,一共花去了近半年的时间,前前后后各种下载源码,编译源码,系统不兼容,版本适配,虚拟机配置困难重重,总算是录制完成,目前应该算是全网最全的源码编译课程。
/p/46c63dfd5c89
Android系统定制和源码开发以及源码编译
本文由zhh_happig投稿。
zhh_happig的博客地址:
/u/d82bd37b1d29
上篇文章讲述了如何在地图显示位置点,这篇文章主要讲述如何在地图上画运动轨迹,以及地图图层点击事件的处理。
很多运动类的app都有画出跑步者运动轨迹的需求,拿咕咚来说,我们看一下它的效果图:
本篇将要实现的效果
1.跑步结束后,静态的画出整个运动轨迹
2.跑步过程中,时时动态的画运动轨迹
如何实现:
1.将点与点连成线,在百度地图MapView上画出线条图层;
2.获取定位点List&LatLng&:通过百度定位sdk:LocationClient类获取,户外运动画运动轨迹,要求位置点的精度高,所以我们必须使用gps定位类型的位置结果。
//允许使用gps定位mOption.setOpenGps(true);
更多百度定位sdk参数详解请阅读篇头百度地图(一)文章
/p/29ccac3e1e42
静态画整个运动轨迹
用到的coordinateConvert方法:
运动轨迹效果
2.添加起始图标图层、点击图层响应事件
运动轨迹效果,点击图标弹出信息窗口
点击图标弹出信息窗口弹出Toast
弹出Toast.
到这里,运动结束后画出整个轨迹图和图层添加点击事件就介绍完了。
实时动态的画运动轨迹
时时动态画运动轨迹效果
运动轨迹:箭头为当前位置和方向
关键在于取点:gps刚接收到信号时返回的一些点精度不高,容易造成位置偏移,如何取点很重要。
首先开始初始化工作,开启定位:
重点就在于收到返回的位置点,绘制路线:
用到的辅助方法:
退出记得释放资源
注:我们画运动轨迹要求定位sdk返回的位置精度很高,轨迹的效果才会好,因而必须接受gps位置点。
但是gps位置的在刚开始收到信号时精度不高,会出现位置漂移的情况,所以要选取一个精度较好的点。在建筑物、桥梁、大树、隧道里面,gps信号不好,精度不高,所以在开阔地带,运动轨迹效果更好。
/zhuhaoHappig/BaiduMapApi
更多百度地图、定位sdk参数详解请阅读:
Android百度地图(一):百度地图定位sdk 类方法参数、定位原理详细介绍
/p/29ccac3e1e42
Android百度地图(二):百度定位与地图结合显示位置点
/p/fdd1ba783495
以上文章内容,是本人工作中的总结,供大家参考,有误的地方还请指正。
如果你有想学习的文章直接留言,我会整理征稿。如果你有好的文章想和大家分享欢迎投稿,直接向我投递文章链接即可。
责任编辑:
声明:本文由入驻搜狐号的作者撰写,除搜狐官方账号外,观点仅代表作者本人,不代表搜狐立场。
今日搜狐热点后使用快捷导航没有帐号?
暂时没有人问过相似的问题,你可以做第一个提问题的人
查看: 9042|回复: 30
关于百度地图绘制运动轨迹的问题,急!!!
现在在做实时记录运动轨迹的功能,在网上找到一个demo仿照做一遍,基本思路是定时定位取点,得到两个经纬度后构建点GeoPoint,然后放到数组中区,完了通过这两点连线形成轨迹。我之前想着将取点的间隔时间设置的越短,那么绘制出的轨迹路线应该越真实,但是现在轨迹能够绘制,还是出现以下几个问题,求指教:1、多次刷新定位时误差会越来越大,是我的代买问题还是GPS定位本身误差导致的?2、绘制轨迹的时候即使走的是直线也会出现折线的情况,如果是个环线轨迹还会出现轨迹交叉。求大牛指教,急!急!急。
第一个问题&&请到定位版块进行咨询
第二个 我觉得还是取决于定位是否完全准确吧& &精确的定位 就不会出现你说的这个问题
& & 谢谢。我这就换到那里去,但还是想问一下怎样做到精确定位,我是按照demo里面写的,所以不知道是我的代码导致的常出现误差还是非人为因素导致的。
求demo&&邮箱emailto:[/email]
求demo 邮箱emailto:[/email]
求demo 邮箱emailto:[/email]
楼主发我一份demo吧 邮箱email:
楼主发我一份demo吧 邮箱email:
楼主,求实时记录运动轨迹的demo借我参考一下,拜托了,邮箱:emailto:[/email]
能把DEMO发一份学习一下么~谢谢emailto:[/email]
楼主请也发我一份demo给我吧,初学者好苦逼,哎& &邮箱emailto:[/email] 谢谢~~
楼主能不能给我看看你的demo,我现在画轨迹明明是直线的会突然歪出去一个点然后又会有点返回去email:emailto:[/email] 不胜感激
也碰到同样的需求,求demo帮助看一下,emailto:[/email];
楼主你好。我现在也遇到一样的需求,发一份源代码吧!谢谢
楼主你好。我现在也遇到一样的需求,发一份源代码吧!谢谢
emailto:[/email]
楼主你好,我也遇到同样的问题,能发份Demo参考参考吗? 谢谢了~&&邮箱:emailto:[/email]
楼主你好,我也遇到同样的问题,能发个demo吗?描绘运动轨迹.。 emailto:[/email]
楼主。我是个苦逼初学者,求你的源码一份学习万分感谢 emailto:[/email]
楼主,求可怜啊
看看我这个例子
看看我这个例子http://bbs./forum.php?mod=viewthread&tid=99867
我使用百度定位获取的点不准确的, 就算手机不动,获取的定位点的坐标都会变化,你的会出现这个情况么
我使用百度定位获取的点不准确的, 就算手机不动,获取的定位点的坐标都会变化,你的会出现这个情况么 ...
那是因为没搜到gps或者gps信号不好,就出现漂移了,可以自己加个gps搜星数判断,大于3再开始画轨迹
大神可以给一下关于实时监控运动轨迹,并绘制运动轨迹,邮箱emailto:[/email]
大神可以给一下关于实时监控运动轨迹,并绘制运动轨迹,邮箱emailto:[/email]
大神可以给一下关于实时监控运动轨迹,并绘制运动轨迹,邮箱emailto:
楼主,请把demo发一份可以吗?现在遇到同样的需求了,多谢!
楼主求做好的demo,急!毕业设计需要啊
楼主求帮忙呀。感激不尽。
最后说一句,求demo。。
楼主求帮忙呀。感激不尽。&&
最后说一句,求demo。。
今天会给Demo的
今天会给Demo的
小车轨迹demo。见附件
14:22 上传
点击文件名下载附件
8.51 KB, 下载次数: 122
小车轨迹的demo
楼主,求Demo,邮箱:最近在研究一个类似的项目,万分感谢!!!!!&
Powered by334被浏览100956分享邀请回答/blog/488659 256 条评论分享收藏感谢收起154 条评论分享收藏感谢收起查看更多回答IOS中如何在百度地图上画轨迹
&UIKit/UIKit.h&
&CoreLocation/CoreLocation.h&
#import "AppDelegate.h"
#import "BMapKit.h"
@interface MonitorTrackplayback :
UIViewController&BMKMapViewDelegate,BMKSearchDelegate, CLLocationManagerDelegate,UITextFieldDelegate&{
& & UINavigationBar *customNavigationB
& // the map view
BMKMapView* _mapV
& NSMutableArray *
& & NSMutableArray * allCoordinateA
BMKPolyline * routeL
BMKPolylineView *
routeLineV
& & CLLocationManager * locationM
& CLLocationCoordinate2D curL
& & UITextField *startTimeTextF
& & UITextField *endTimeTextF
BMKSearch *_
& & UIDatePicker *_startTimedateP
& & UIDatePicker *_endTimedateP
& //工具栏
& & UIToolbar *_toolB
& & UIButton *_btnC
& & UIButton *_btnC
& & UIButton *_btnNotL
& & BMKMapRect _routeR
& & NSTimer *&
& & BOOL isC
& & BOOL isNotL
& & GPSInfo *gpsI
& //起始时间参数
& & NSString *
& & NSString *
& & id&OBDReport&
& // location manager
& & CLLocationManager* _locationM
& // current location
& & CLLocation* _currentL
@property (nonatomic,
retain) BMKMapView*
@property (nonatomic,retain)BMKPolyline
@property (nonatomic,retain)BMKPolylineView
* routeLineV
"MonitorTrackplayback.h"
#import "SGInfoAlert.h"
#define ADDRESS
@"http://61.144.244.100:8088/KLSInterface/obd"
#define StartTimeDateLabelTag <span STYLE="color: #02
#define EndTimeDateLabelTag <span STYLE="color: #03
@interface MonitorTrackplayback
@implementation
MonitorTrackplayback
@synthesize mapView =
@synthesize
routeLine,routeLineV
- (id)initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle
*)nibBundleOrNil
& & self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
& & if (self) {
& & DBAccount= [[accountDB alloc]init];
& return self;
&&//获取轨迹点
- (void)getOBDdate{
//获取数据
& & NSURL *url = [NSURL URLWithString:ADDRESS];
& dsservice=(id&OBDReport&)[CWHessianConnection
proxyWithURL:url protocol:@protocol(OBDReport)];
[CWHessianArchiver
seClassName:@"com.icalinks.obd.vo.GPSInfo"
forClass:[GPSInfo class]];//向服务端传递对象
[CWHessianUnarchiver
setProtocol:@protocol(GPSInfo) forClassName:@"com.icalinks.obd.vo.GPSInfo"];
& self.mapView.delegate = self;&
(startTimeTextField.text
& NSDateFormatter *formatter =[[[NSDateFormatter alloc] init] autorelease];
& NSDate *date
= [NSDate date];
& & [[NSDate date] timeIntervalSince1970];
& [formatter setDateFormat:@"yyyy-MM-dd 05:59:59"];
& startTimeTextField.text = [formatter stringFromDate:date];
(endTimeTextField.text
& NSDateFormatter *formatter =[[[NSDateFormatter alloc] init] autorelease];
& NSDate *date
= [NSDate date];
& & [[NSDate date] timeIntervalSince1970];
& [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
& endTimeTextField.text = [formatter stringFromDate:date];
([Utilities checkAccountsExist]) {
([adata count]==<span STYLE="color: #) {
& NSArray *gsp=[[[NSArray alloc]initWithArray:[dsservice getVehicleHistory:[DBAccount getLoadingname] :[DBAccount getLoadingPassword] :startTimeTextField.text
:endTimeTextField.text]]autorelease];
adata = [[NSMutableArray alloc] init];
NSMutableArray *tiparraysd =
[[NSMutableArray alloc]init];
for (gpsInfo in gsp) {
& & if (gpsInfo.latitude != <span STYLE="color: # &&
gpsInfo.longitude!= <span STYLE="color: #) {
& NSString *
la = [NSString stringWithFormat:@"%f",gpsInfo.latitude];
& NSString *
lb = [NSString stringWithFormat:@"%f",gpsInfo.longitude];
& NSString *lc
= [NSString stringWithFormat:@"%d",gpsInfo.direction];
& NSMutableArray * arr = [[NSMutableArray alloc] init];
& [arr addObject:la];
& [arr addObject:lb];
& [tiparraysd addObject:lc];
addObject:arr];
allCoordinateArr =
[[NSMutableArray alloc] init];
[self initBMKPolyLine:adata];
adata = [[NSMutableArray alloc] init];
& NSArray *gsp=[[[NSArray alloc]initWithArray:[dsservice getVehicleHistory:[DBAccount getLoadingname] :[DBAccount getLoadingPassword] :startTimeTextField.text
:endTimeTextField.text]]autorelease];
NSMutableArray *tiparraysd =
[[NSMutableArray alloc]init];
for (gpsInfo in gsp) {
& & if (gpsInfo.latitude != <span STYLE="color: # &&
gpsInfo.longitude!= <span STYLE="color: #) {
& NSString *
la = [NSString stringWithFormat:@"%f",gpsInfo.latitude];
& NSString *
lb = [NSString stringWithFormat:@"%f",gpsInfo.longitude];
& NSString *lc
= [NSString stringWithFormat:@"%d",gpsInfo.direction];
& NSMutableArray * arr = [[NSMutableArray alloc] init];
& [arr addObject:la];
& [arr addObject:lb];
& [tiparraysd addObject:lc];
addObject:arr];
[self initBMKPolyLine:adata];
& & }else {
& NSString
*info = @"请先登陆!";
& [SGInfoAlert
showInfo:info
& & bgColor:[[UIColor whiteColor] CGColor]
inView:self.mapView
& & vertical:<span STYLE="color: #.7];
&处理轨迹点
(void)initBMKPolyLine:(NSArray *)data
& // so we can easily zoom in on it.
& & BMKMapPoint northEastP
& & BMKMapPoint
southWestP&
BMKMapPoint * pointArr =
malloc(sizeof(CLLocationCoordinate2D) * [data
CLLocationCoordinate2D *
locationCoodinateArr = malloc(sizeof(CLLocationCoordinate2D) * [data count]);
& NSLog(@"LineDataCount
============================%d",[data count]);
for (int i = <span STYLE="color: #; i & [data count]; i ++) {
NSArray * coordinateArr = [data
objectAtIndex:i];
CLLocationDegrees latitude =
[[coordinateArr objectAtIndex:<span STYLE="color: #] doubleValue];
CLLocationDegrees longitude =
[[coordinateArr objectAtIndex:<span STYLE="color: #] doubleValue];
CLLocationCoordinate2D
coordinate = CLLocationCoordinate2DMake(latitude,
longitude);
& NSDictionary
*tip = BMKBaiduCoorForWgs84(coordinate);
& CLLocationCoordinate2D coordinate1 =
BMKCoorDictionaryDecode(tip);
& BMKMapPoint
point = BMKMapPointForCoordinate(coordinate1);
& & // if it is the first
point, just use them, since we have nothing to compare to yet.
& if (i ==
<span STYLE="color: #) { &
northEastPoint = &
southWestPoint = &
if (point.x &
northEastPoint.x)
& & northEastPoint.x = point.x; &
if(point.y &
northEastPoint.y)
& & northEastPoint.y = point.y; &
if (point.x &
southWestPoint.x)
& & southWestPoint.x = point.x; &
if (point.y &
southWestPoint.y)
& & southWestPoint.y = point.y; &
& pointArr[i] =
locationCoodinateArr[i] = coordinate1;
CLLocation * currentLocation =
[[[CLLocation alloc] initWithLatitude:latitude longitude:longitude] autorelease];
[allCoordinateArr addObject:currentLocation];
// create the polyline based on the array of points.
self.routeLine = [BMKPolyline polylineWithPoints:pointArr count:[data count]];
// routeLine = [BMKPolyline
polylineWithCoordinates:locationCoodinateArr count:[data
& & _routeRect = BMKMapRectMake(southWestPoint.x, southWestPoint.y, northEastPoint.x - southWestPoint.x, northEastPoint.y - southWestPoint.y);&
free(pointArr);
[self.mapView addOverlay:self.routeLine];
[self setRegion:allCoordinateArr];
(BOOL)RefreshMap
& & if (self.routeLine!=nil) {
& self.routeLine =nil;
& & if(self.routeLine!=nil)
& & [self.mapView removeOverlay:self.routeLine];
& self.routeLine =nil;
& // create the overlay
getOBDdate];
& // add the overlay to the map
& & if (nil
!= self.routeLine) {
& & [self.mapView addOverlay:self.routeLine];
& & if ([adata count]!=<span STYLE="color: #) {
& & }else {
& // zoom in on the
//& & [self zoomInOnRoute];
//设置地图当前显示的区域
(void)setRegion:(NSArray * )arr
& & if ([adata count]!=<span STYLE="color: #) {
& & // determine the
extents of the trip points that were passed in, and zoom in to that
& CLLocationDegrees maxLat = -<span STYLE="color: #;
& CLLocationDegrees maxLon = -<span STYLE="color: #0;
& CLLocationDegrees minLat = <span STYLE="color: #;
& CLLocationDegrees minLon = <span STYLE="color: #0;
i = <span STYLE="color: #; i & [arr
count]; i++)
CLLocation* currentLocation =
[arr objectAtIndex:i];
if(currentLocation.coordinate.latitude & maxLat)
& & maxLat =
currentLocation.coordinate.latitude;
if(currentLocation.coordinate.latitude & minLat)
& & minLat =
currentLocation.coordinate.latitude;
if(currentLocation.coordinate.longitude & maxLon)
& & maxLon =
currentLocation.coordinate.longitude;
if(currentLocation.coordinate.longitude & minLon)
& & minLon =
currentLocation.coordinate.longitude;
& & BMKCoordinateRegion
& region.center.latitude &
& = (maxLat + minLat) / <span STYLE="color: #;
& region.center.longitude&
& = (maxLon + minLon) / <span STYLE="color: #;
& region.span.latitudeDelta& = maxLat -
& region.span.longitudeDelta = maxLon - minL
& [self.mapView setRegion:region];
& & }else {
& NSString
*info = @"这段时间内无轨迹!";
& [SGInfoAlert
showInfo:info
& & bgColor:[[UIColor whiteColor] CGColor]
inView:self.mapView
& & vertical:<span STYLE="color: #.7];
在地图上画线
(BMKOverlayView
*)mapView:(BMKMapView *)mapView
viewForOverlay:(id
&BMKOverlay&)overlay
& NSLog(@"EntrySucceed!");
& BMKOverlayView* overlayView = nil;
& if(overlay
== self.routeLine)
& //if we have not yet created an overlay
view for this overlay, create it now.
if(nil == self.routeLineView)
NSLog(@"___________************************&&&&&&&&&&&&&&&&%g",gpsInfo.latitude);
routeLineView =
[[[BMKPolylineView alloc]
initWithPolyline:routeLine] autorelease];
& & routeLineView.fillColor = [UIColor orangeColor];
& & routeLineView.strokeColor = [UIColor redColor];
routeLineView.lineWidth
= <span STYLE="color: #;
overlayView = routeLineView;
-(void)mapView:(BMKMapView *)mapView
didFailToLocateUserWithError:(NSError *)error{
[mapView setShowsUserLocation:NO];
(void)viewDidLoad
viewDidLoad];
& self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"整背景.png"]];
& //picker上的toolBar
& & if(!_toolBar){
& & _toolBar =
[[UIToolbar
initWithFrame:CGRectMake(<span STYLE="color: #.0,
<span STYLE="color: #.0, <span STYLE="color: #0.0,
<span STYLE="color: #.0)];
& _toolBar.barStyle = UIBarStyleBlackTranslucent;
& _btnCancel =
buttonWithType:UIButtonTypeCustom];
& & _btnCancel.frame = CGRectMake(<span STYLE="color: #.0, <span STYLE="color: #.0, <span STYLE="color: #, <span STYLE="color: #.0);
[_btnCancel
setBackgroundImage:[Utilities
getImageBySmallPNG:@"按钮选中.png"]
forState:UIControlStateNormal];
[_btnCancel
setTitle:@"取消"
forState:UIControlStateNormal];
& _btnCancel.titleLabel.font =
[UIFont systemFontOfSize:<span STYLE="color: #.0f];
[_btnCancel
addTarget:self action:@selector(toolButtonCancelPressed:)
forControlEvents:UIControlEventTouchUpInside];
[_toolBar addSubview:_btnCancel];
& _btnConfirm =
buttonWithType:UIButtonTypeCustom];
& & _btnConfirm.frame = CGRectMake(<span STYLE="color: #0.0, <span STYLE="color: #.0, <span STYLE="color: #.0, <span STYLE="color: #.0);
[_btnConfirm
setBackgroundImage:[Utilities
getImageBySmallPNG:@"按钮选中.png"]
forState:UIControlStateNormal];
[_btnConfirm
setTitle:@"确定"
forState:UIControlStateNormal];
& _btnConfirm.titleLabel.font =
[UIFont systemFontOfSize:<span STYLE="color: #.0f];
[_btnConfirm
addTarget:self action:@selector(toolButtonConfirmPressed:)
forControlEvents:UIControlEventTouchUpInside];
[_toolBar addSubview:_btnConfirm];
& UIButton *EnlargeButton = [UIButton buttonWithType:UIButtonTypeCustom];
& & EnlargeButton.frame = CGRectMake(<span STYLE="color: #, <span STYLE="color: #,
<span STYLE="color: #, <span STYLE="color: #);
& & [EnlargeButton setImage:[Utilities getImageBySmallPNG:@"放大地图.png"]
forState:UIControlStateNormal];
[EnlargeButton addTarget:self
action:@selector(MapEnlarge) forControlEvents:UIControlEventTouchUpInside];
& UIButton *NarrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
& & NarrowButton.frame = CGRectMake(<span STYLE="color: #, <span STYLE="color: #0, <span STYLE="color: #, <span STYLE="color: #);
& & [NarrowButton setImage:[Utilities getImageBySmallPNG:@"缩小地图.png"]
forState:UIControlStateNormal];
[NarrowButton addTarget:self
action:@selector(MapNarrow) forControlEvents:UIControlEventTouchUpInside];
& & if (!self.mapView) {
& self.mapView = [[BMKMapView alloc]init];
[self.mapView setShowsUserLocation:YES];
& & self.mapView.frame = CGRectMake(<span STYLE="color: #, <span STYLE="color: #,
<span STYLE="color: #0, <span STYLE="color: #0);
& self.mapView.scrollEnabled = YES;
& self.mapView.delegate = self;&
& & [self.mapView addSubview:EnlargeButton];
& & [self.mapView addSubview:NarrowButton];
& & [self.view addSubview:self.mapView];
& NSDateFormatter *formatter =[[[NSDateFormatter alloc]
init] autorelease];
& & NSDate *date = [NSDate date];
timeIntervalSince1970];
[formatter setDateFormat:@"yyyy-MM-dd 05:59:59"];
& if(!_startTimedatePicker){
& & _startTimedatePicker
= [[UIDatePicker alloc]
& _startTimedatePicker.datePickerMode = UIDatePickerModeDateAndTime;
& & NSDate* minDate = [formatter dateFromString:[formatter stringFromDate:date]];
& _startTimedatePicker.date
& if(!_endTimedatePicker){
& _endTimedatePicker = [[UIDatePicker alloc] init];
& _endTimedatePicker.datePickerMode = UIDatePickerModeDateAndTime;
& & UIView * aview = [[UIView alloc]init];
& & aview.frame = CGRectMake(<span STYLE="color: #, <span STYLE="color: #0,
<span STYLE="color: #0, <span STYLE="color: #);
aview.backgroundColor =
[UIColor darkGrayColor];
& & aview.alpha = <span STYLE="color: #.7f;
& & [self.view addSubview:aview];
& & [aview release];
& UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
& & button2.frame = CGRectMake(<span STYLE="color: #, <span STYLE="color: #5,
<span STYLE="color: #5, <span STYLE="color: #);
[button2 setImage:[UIImage imageNamed:@"时间背景.png"]
forState:UIControlStateNormal];
[button2 setImage:[UIImage imageNamed:@"时间背景选中.png"]
forState:UIControlStateHighlighted];
& & [self.view addSubview:button2];
& startTimeTextField = [[UITextField alloc]init];
& startTimeTextField.frame
= CGRectMake(<span STYLE="color: #,
<span STYLE="color: #5, <span STYLE="color: #0,
<span STYLE="color: #);
& startTimeTextField.textColor =
[UIColor whiteColor];
& startTimeTextField.inputView = _startTimedatePicker;
& startTimeTextField.inputAccessoryView = _toolBar;
& startTimeTextField.delegate = self;
& startTimeTextField.tag
StartTimeDateLabelTag;
& startTimeTextField.font
= [UIFont fontWithName:@"Helvetica-Bold" size:<span STYLE="color: #.0f];
& startTimeTextField.backgroundColor = [UIColor clearColor];
[self.view
addSubview:startTimeTextField];
& & UIImageView *imageView2 = [[UIImageView alloc]init];
& & imageView2.frame = CGRectMake(<span STYLE="color: #5, <span STYLE="color: #5, <span STYLE="color: #,<span STYLE="color: #);
& & imageView2.image = [UIImage imageNamed:@"箭头.png"];
& & [self.view addSubview:imageView2];
& & [imageView2 release];
& & UIImageView *imageView3 = [[UIImageView alloc]init];
& & imageView3.frame = CGRectMake(<span STYLE="color: #, <span STYLE="color: #2, <span STYLE="color: #, <span STYLE="color: #);
& & imageView3.image = [UIImage imageNamed:@"icon-clock.png"];
& & [self.view addSubview:imageView3];
& & [imageView3 release];
& & UIImageView *imageView4 = [[UIImageView alloc]init];
& & imageView4.frame = CGRectMake(<span STYLE="color: #0, <span STYLE="color: #2, <span STYLE="color: #, <span STYLE="color: #);
& & imageView4.image = [UIImage imageNamed:@"icon-clock.png"];
& & [self.view addSubview:imageView4];
& & [imageView4 release];
& UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
& & button3.frame = CGRectMake(<span STYLE="color: #5, <span STYLE="color: #5, <span STYLE="color: #5, <span STYLE="color: #);
[button3 setImage:[UIImage imageNamed:@"时间背景.png"]
forState:UIControlStateNormal];
[button3 setImage:[UIImage imageNamed:@"时间背景选中.png"]
forState:UIControlStateHighlighted];
& & [self.view addSubview:button3];
& endTimeTextField = [[UITextField alloc]init];
& & endTimeTextField.frame = CGRectMake(<span STYLE="color: #0, <span STYLE="color: #5, <span STYLE="color: #0, <span STYLE="color: #);
& endTimeTextField.textColor =
[UIColor whiteColor];
& endTimeTextField.inputView = _endTimedatePicker;
& endTimeTextField.inputAccessoryView = _toolBar;
& endTimeTextField.delegate = self;
& endTimeTextField.font
= [UIFont fontWithName:@"Helvetica-Bold" size:<span STYLE="color: #.0f];
& endTimeTextField.backgroundColor = [UIColor clearColor];
& endTimeTextField.tag
EndTimeDateLabelTag;
[self.view
addSubview:endTimeTextField];
(!startTimeTextField.text)
& NSDateFormatter *formatter =[[[NSDateFormatter alloc] init] autorelease];
& NSDate *date
= [NSDate date];
& & [[NSDate date] timeIntervalSince1970];
& [formatter setDateFormat:@"yyyy-MM-dd 05:59:59"];
& startTimeTextField.text = [formatter stringFromDate:date];
(!endTimeTextField.text)
& NSDateFormatter *formatter =[[[NSDateFormatter alloc] init] autorelease];
& NSDate *date
= [NSDate date];
& & [[NSDate date] timeIntervalSince1970];
& [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
& endTimeTextField.text = [formatter stringFromDate:date];
& customNavigationBar = [[AppDelegate shareAppDelegate]
createDefaultNavigationBarWithtile:@"汽车卫士-轨迹回放"];
[self.view
addSubview:customNavigationBar];
(void)MapEnlarge
& & [self.mapView zoomIn];
(void)MapNarrow
& & [self.mapView zoomOut];
#pragma mark - UITextFieldDelegate Methods
//显示picker中的内容
(BOOL)textFieldShouldBeginEditing:(UITextField
*)textField{
& _btnNotLimit.hidden
& if(textField.tag ==
StartTimeDateLabelTag ||
textField.tag
EndTimeDateLabelTag){
& _btnNotLimit.tag = [textField tag];
& _btnNotLimit.hidden = NO;
& return YES;
//得到并在textfield中显示获得的值
(BOOL)textFieldShouldEndEditing:(UITextField
*)textField{
& if(isCancel){
& isCancel =
& if(isNotLimit){
& isNotLimit =
& & if(textField.tag == StartTimeDateLabelTag){
& if ([Utilities checkAccountsExist]) {
& & NSDateFormatter
*formatter = [[NSDateFormatter
alloc] init];
& [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
& textField.text = [formatter stringFromDate:[_startTimedatePicker date]];
& startTimeTextField.text = textField.text;
& & NSLog(@"startTimeTextField.text=============================%@",startTimeTextField.text);
& & [self feedBackAction];
& & timer =
scheduledTimerWithTimeInterval:<span STYLE="color: #.1
target:self
& & selector:@selector(stopaction:)
& & userInfo:nil
repeats:NO];
& [self getOBDdate];
& [formatter release];
& & }if ( textField.tag == EndTimeDateLabelTag) {
& if ([Utilities checkAccountsExist]) {
& & NSDateFormatter
*formatter = [[NSDateFormatter
alloc] init];
& [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
& textField.text = [formatter stringFromDate:[_endTimedatePicker date]];
& endTimeTextField.text = textField.text;
& & NSLog(@"endTimeTextField.text=============================%@",endTimeTextField.text);
& & [self feedBackAction];
& & timer =
scheduledTimerWithTimeInterval:<span STYLE="color: #.1
& target:self
selector:@selector(stopaction:)
userInfo:nil
repeats:NO];
& [self getOBDdate];
& [formatter release];
& return YES;
#pragma mark - ButtonAction Methods
#pragma mark - ButtonAction Methods
//取消按钮按下事件
(void)toolButtonCancelPressed:(id)sender{
& & isCancel = YES;
[startTimeTextField
resignFirstResponder];
[endTimeTextField
resignFirstResponder];
//确定按钮按下事件
(void)toolButtonConfirmPressed:(id)sender{
& & isCancel = NO;
[startTimeTextField
resignFirstResponder];
[endTimeTextField
resignFirstResponder];
(void)feedBackAction{
[AppDelegate
startLoading:self.view
withLabel:@"正在加载数据,请稍候……"];
(void)stopaction:(NSTimer *)timer
& if([netConection connectedToNetwork])
([self RefreshMap]) {
[AppDelegate stopLoading];
& [AppDelegate
stopLoading];
NSString *info = @"这段时间内无轨迹!";
[SGInfoAlert showInfo:info
& bgColor:[[UIColor whiteColor] CGColor]
& & inView:self.mapView
& vertical:<span STYLE="color: #.7];
& [AppDelegate stopLoading];
& & }else {
& & NSString *info
= @"网络连接失败!请查看网络是否连接正常!";
& [SGInfoAlert
showInfo:info
& & bgColor:[[UIColor whiteColor] CGColor]
inView:self.view
& & vertical:<span STYLE="color: #.7];
& [AppDelegate
stopLoading];
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 高德地图实时绘制轨迹 的文章

 

随机推荐