ios ArcGIS双屏联动,双屏显示功能

本文介绍如何在iOS应用中实现ArcGIS地图的双屏显示和联动功能。通过创建两个AGSMapView对象,分别设置矢量图层和影像图层,并通过监听地图的平移和缩放事件,保持两屏地图的一致性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      

  

/**

VectorMap和ImageMap是通过AGSMapView实例出来的对象

**/   

  self.VectorMap = [[AGSMapView alloc]initWithFrame:CGRectMake(0, 0, viewWidth/2, viewHeight)];

  self.VectorMap.tag = 0;

  self.VectorMap.layerDelegate = self;

  self.VectorMap.touchDelegate = self;

 [self addSubview:self.VectorMap];

  self.VectorMap.layer.borderColor = [UIColor zjcChangeFloat:@"#555555"].CGColor;

  self.VectorMap.layer.borderWidth = 0.8;

        

  self.ImageMap = [[AGSMapView alloc]initWithFrame:CGRectMake(viewWidth/2, 0, viewWidth/2, viewHeight)];

  self.ImageMap.tag = 1;

  self.ImageMap.layerDelegate = self;

  self.ImageMap.touchDelegate = self;

  [self addSubview:self.ImageMap];

   self.ImageMap.layer.borderColor = [UIColor zjcChangeFloat:@"#555555"].CGColor;

   self.ImageMap.layer.borderWidth = 0.8;


//这是影像 和 矢量

//        TianMapLayer *TianDiTuLyrimage = [[TianMapLayer alloc]initWithType:TianMapTypeImage2000 localServiceURL:nil];

//        TianMapLayer *TianDiTuLyr_Annoimage = [[TianMapLayer alloc]initWithType:TianMapTypeImageAnnotationChinese2000 localServiceURL:nil];

//        TianDiTuLyrimage.visible = NO;

//        TianDiTuLyr_Annoimage.visible = NO;


//        TianMapLayer *TianDiTuLyrSL = [[TianMapLayer alloc]initWithType:TianMapTypeImage2000 localServiceURL:nil];

//        TianMapLayer *TianDiTuLyr_SL = [[TianMapLayer alloc]initWithType:TianMapTypeImageAnnotationChinese2000 localServiceURL:nil];

//        TianDiTuLyrSL = NO;

//        TianDiTuLyr_SL.visible = NO;

       

//分别加入到mapView容器中,下面代码只显示加入影响的,矢量的我没写(方法和影响一样)

        [self.ImageMap mapLayerForName:@"tiandituimage"].visible = YES;

        [self.ImageMap mapLayerForName:@"image2000"].visible = YES;


//下面才是代码的关键。

- (void)respondToEnvChanged: (NSNotification*) notification {

    

    AGSSpatialReference *sccc = [AGSSpatialReference spatialReferenceWithWKID:4490];

    

    AGSEnvelope *extent = [AGSEnvelope envelopeWithXmin:MM ymin:YY xmax:ZZ ymax:DD spatialReference:sccc];

    

    [self.VectorMap zoomToEnvelope:extent animated:YES];

    

    [self.VectorMap zoomToEnvelope:extent animated:YES];

    

}


- (void)respondToEnvChange: (NSNotification*) notification {

    

    AGSMapView *mapView = (AGSMapView *)notification.object;

    

    NSInteger mapName = mapView.tag;

    

    CGRect rect = mapView.bounds;

    

    AGSEnvelope *env = [mapView toMapEnvelope:rect];

    

    if (mapName == 0) {

        

        [self.ImageMap zoomToEnvelope:env animated:YES];

    }

    else

    {

        [self.VectorMap zoomToEnvelope:env animated:YES];

        [self.MapView zoomToEnvelope:env animated:YES];

        

    }

    

}


//主控制器里面添加通知。

        [[NSNotificationCenter defaultCenter] addObserver:self.doubleScreenView selector:@selector(respondToEnvChange:) name:AGSMapViewDidEndPanningNotification object:nil];

        

        // register for zoom notifications  AGSMapViewDidLoadNotification

        [[NSNotificationCenter defaultCenter] addObserver:self.doubleScreenView selector:@selector(respondToEnvChange:)  name:AGSMapViewDidEndZoomingNotification object:nil];

        

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(respondToEnvChanged:)  name:AGSMapViewDidLoadNotification object:nil];

        

        AGSEnvelope *envelope = [[AGSEnvelope alloc]initWithSpatialReference:self.spatialReference];

        

        [self.doubleScreenView.VectorMap zoomToEnvelope:envelope animated:YES];

        [self.doubleScreenView.ImageMap zoomToEnvelope:envelope animated:YES];

        



        


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值