ArcGIS Runtime SDK for iOS(四) ---使用geometry的原始数据重绘折线
来源:互联网 发布:零基础学qt4编程 编辑:程序博客网 时间:2024/04/30 00:00
2016.4.15 武汉 小雨
by SevenJohs.
- 概述
通过已经绘制的线的基础上,得到JSON数据,使用geometry的JSON字符串的原始数据重绘折线。 内容
- 绘制出断点折线;
- 不使用定时器一次性画出;
- 使用定时器重绘。
绘制出断点折线
/** * 绘制线条 */-(void)drawPolyLine{ _pointIndex = 0; _polyline = nil; _polylineSymbol = [AGSSimpleLineSymbol simpleLineSymbolWithColor:[UIColor blueColor] width:4]; [self timerDefination];}/** * 更新PolyLine,使其绘制出每隔20个点,绘制出独立的线段。 */-(void)updatePloyline { if(!_mutPointArr || [_mutPointArr count] <= _pointIndex) { return; } if(!_polyline) { _polyline = [[AGSMutablePolyline alloc]init]; [_polyline addPathToPolyline]; }// if(_pointIndex%2 == 0 ){// [_polyline addPathToPolyline];// // } [_polyline addPointToPath:_mutPointArr[_pointIndex]]; if(_pointIndex>0) { if(!_graphic) { [_graphicLayer removeGraphic:_graphic]; } } //设置折线属性 _graphic = [AGSGraphic graphicWithGeometry:_polyline symbol:_polylineSymbol attributes:nil infoTemplateDelegate:nil]; [_graphicLayer addGraphic:_graphic]; _pointIndex++;}
- 不使用定时器一次性画出
-(void)drawTrack { if(!_mapView || ![_mapView loaded]){ return; } NSDictionary* geoJSON = [_polyline encodeToJSON]; NSString* jsonStr = [geoJSON description]; _trackDataLine = [AGSPolyline polylineWithJSON:geoJSON]; NSInteger paths = [_trackDataLine numPaths]; AGSMutablePolyline* trackLine = [[AGSMutablePolyline alloc]init]; [trackLine addPathToPolyline]; for (int path = 0; path < paths; path++) { NSInteger numPntOnPath = [_trackDataLine numPointsInPath:path]; for (int i = 0; i < numPntOnPath; i++) { AGSPoint* pnt = [_trackDataLine pointOnPath:path atIndex:i]; AGSPoint* newPnt = [AGSPoint pointWithX:pnt.x+0.01 y:pnt.y spatialReference:_mapView.spatialReference]; [trackLine addPointToPath:newPnt]; } [trackLine addPathToPolyline]; } if(![trackLine isEmpty]){ AGSSimpleLineSymbol* symbol = [AGSSimpleLineSymbol simpleLineSymbolWithColor:[UIColor purpleColor] width:5]; AGSGraphic* graphic = [AGSGraphic graphicWithGeometry:trackLine symbol:symbol attributes:nil infoTemplateDelegate:nil]; [_graphicLayer addGraphic:graphic]; } _timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateTrack) userInfo:nil repeats:YES]; [_timer fire];}
- 使用定时器重绘。
-(void)updateTrack{ if(_currentPath == 0 && _currentIndex == 0){ [_trackLine addPathToPolyline]; } NSInteger paths = [_trackDataLine numPaths]; if(_currentPath>= paths){ [self stopTimer]; return; } NSInteger numPntOnPath = [_trackDataLine numPointsInPath:_currentPath]; if(_currentIndex >= numPntOnPath){ _currentPath++; _currentIndex = 0; [_trackLine addPathToPolyline]; return; }else{ AGSPoint* pnt = [_trackDataLine pointOnPath:_currentPath atIndex:_currentIndex]; AGSPoint* newPnt = [AGSPoint pointWithX:pnt.x+0.02 y:pnt.y spatialReference:_mapView.spatialReference]; [_trackLine addPointToPath:newPnt]; _currentIndex++; } if(![_trackLine isEmpty]){ if(_trackGraphic){ [_graphicLayer removeGraphic:_trackGraphic]; } AGSSimpleLineSymbol* symbol = [AGSSimpleLineSymbol simpleLineSymbolWithColor:[UIColor orangeColor] width:5]; _trackGraphic = [AGSGraphic graphicWithGeometry:_trackLine symbol:symbol attributes:nil infoTemplateDelegate:nil]; [_graphicLayer addGraphic:_trackGraphic]; }}
END
回家了~
1 0
- ArcGIS Runtime SDK for iOS(四) ---使用geometry的原始数据重绘折线
- ArcGIS Runtime SDK for iOS 2.2发布
- ArcGIS Runtime SDK for iOS 升级介绍
- ArcGIS Runtime SDK for iOS开发介绍
- ArcGIS Runtime SDK for iOS简介
- ArcGIS Runtime SDK For iOS 去除水印
- ARCGIS RUNTIME FOR IOS总结(四)
- ArcGIS Runtime SDK for iOS开发系列教程(6)——Tasks使用的一般流程
- ArcGIS Runtime SDK for iOS(二) ---使用定时器绘制由point组成的polyLine,并显示位置坐标
- ArcGIS Runtime SDK for iOS开发系列教程(7)——GeometryService与GeometryEngine使用
- ArcGIS Runtime SDK for iOS开发系列教程(8)——Geoprocessor使用
- 《ArcGIS Runtime SDK for Android开发笔记》——(7)、示例代码arcgis-runtime-samples-android的使用
- ArcGIS Runtime SDK for iOS v2.2.1发布
- 【技术直通车】ArcGIS Runtime SDK for iOS 升级介绍
- 【移动产品】ArcGIS Runtime SDK for iOS v2.2.1发布
- 【移动产品】ArcGIS Runtime SDK for iOS 2.2发布
- ArcGIS Runtime SDK for iOS开发系列教程
- ArcGIS Runtime SDK for IOS 开发之启程篇
- TableViewCell的点击打钩
- 【linux】linux下安装Node.js
- POJ-3100-Root of the Problem,原来是水题,暴力求解~~~
- memcached出现:Fatal error: Call to undefined method Memcached::connect()
- poj 1860 Currency Exchange bellman
- ArcGIS Runtime SDK for iOS(四) ---使用geometry的原始数据重绘折线
- iOS小技巧 - 利用GCD创建更加准确的定时器
- summary:http乱码
- hdu HDU Today2112
- Android设计模式之单例模式的七种写法
- 工厂模式
- hadoop的文件类型
- 欢迎使用CSDN-markdown编辑器
- MAC openfire 无法启动