graphicsLayer 中增加多个graphic 后, 进行缩放定位。然后画一

主要思路就是在graphicsLayer 中加入多个grpahic 后,重新计算出 包含所有graphic 后的Envelope。

然后以Envelope 范围画一个graphic 再增加到graphicsLayer

DLog(@"查询到%d条记录",featureSet.features.count)AGSSimpleLineSymbol *fillSym = [AGSSimpleLineSymbol simpleLineSymbol];fillSym.color = [UIColor whiteColor];for(int i=0; i < featureSet.features.count; i++){AGSGraphic *gra = [featureSet.features objectAtIndex:i];gra.symbol = fillSym;[self.graphicsLayer addGraphic:gra];}if ( self.query1Completed == self.query2Completed && self.query1Completed == TRUE){//开始缩放到路段集合if (self.graphicsLayer.graphics != NULL && self.graphicsLayer.graphics.count >=1) {//accumulate the min/maxdouble xmin = ((AGSGraphic *)self.graphicsLayer.graphics[0]).geometry.envelope.xmin;double ymin = ((AGSGraphic *)self.graphicsLayer.graphics[0]).geometry.envelope.ymin;double xmax = ((AGSGraphic *)self.graphicsLayer.graphics[0]).geometry.envelope.xmax;double ymax = ((AGSGraphic *)self.graphicsLayer.graphics[0]).geometry.envelope.ymax;for (int i=0;i<self.graphicsLayer.graphics.count;i++) {if (((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.xmin < xmin)xmin = ((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.xmin;if (((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.xmax > xmax)xmax = ((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.xmax;if (((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.ymin < ymin)ymin = ((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.ymin;if (((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.ymax > ymax)ymax = ((AGSGraphic *)self.graphicsLayer.graphics[i]).geometry.envelope.ymax;}AGSMutableEnvelope *extent = [AGSMutableEnvelope envelopeWithXmin:xmin ymin:ymin xmax:xmax ymax:ymax spatialReference:self.mapView.spatialReference];[extent expandByFactor:1.5];// 画一个方框,就是在graphicsLayer中加入一个 画好方框的graphicAGSCompositeSymbol *symbol = [AGSCompositeSymbol compositeSymbol];AGSSimpleLineSymbol *lineSymbol = [[AGSSimpleLineSymbol alloc] init];lineSymbol.color = [UIColor colorWithRed:0.286 green:0.690 blue:0.838 alpha:0.200];lineSymbol.width = 1;[symbol addSymbol:lineSymbol];AGSSimpleFillSymbol *fillSymbol = [[AGSSimpleFillSymbol alloc] init];fillSymbol.color = [UIColor colorWithRed:0.939 green:0.940 blue:0.422 alpha:0.200];[symbol addSymbol:fillSymbol];//graphicsLayer 中加入一个graphic。这个graphic 是 指定了 symbol 和 geometry<span style="color:#ff0000;">[self.graphicsLayer addGraphic:[AGSGraphic graphicWithGeometry:extent symbol:symbol attributes:nil]];</span><span style="white-space:pre"></span>// 主线程刷新界面开始if ([NSThread isMainThread]){[self.mapView zoomToEnvelope:extent animated:YES];}else{dispatch_sync(dispatch_get_main_queue(), ^{//Update UI in UI thread here[self.mapView zoomToEnvelope:extent animated:YES];});}// 主线程刷新界面结束}

版权声明:本文为博主原创文章,未经博主允许不得转载。

,往往为了自己的不能失败,而处心积虑前怕狼后怕虎,

graphicsLayer 中增加多个graphic 后, 进行缩放定位。然后画一

相关文章:

  • 【算法】直接插入排序C语言实现
  • 嵌入式 FAAC1.28 在海思HI3518C/HI3518A平台linux中的编译优化
  • Android 动画animation 深入分析
  • Mybatis极其(最)简(好)单(用)的一个分页插件
  • Ext JS Kitchen Sink [Learning by doing](2)ArrayGrid
  • API开发第三篇:PHP的设计模式之完美的单例模式
  • 使用NGUI时遇到物理引擎错误
  • 你感兴趣的文章:

    标签云:

    亚洲高清电影在线, 免费高清电影, 八戒影院夜间, 八戒电影最新大片, 出轨在线电影, 午夜电影院, 在线影院a1166, 在线电影院, 在线观看美剧下载, 日本爱情电影, 日韩高清电影在线, 电影天堂网, 直播盒子app, 聚合直播, 高清美剧, 高清美剧在线观看 EhViewer-E站, E站, E站绿色版, qqmulu.com, qq目录网, qq网站目录,