【问题标题】:Add webMap as layer with ArcGIS mapView for iOS app project使用 ArcGIS mapView for iOS 应用程序项目将 webMap 添加为图层
【发布时间】:2016-02-05 07:23:14
【问题描述】:

我正在尝试将基本的 ArcGIS 工作流程编码到我的 iOS 项目中。我是这个平台的新手,可以使用一些指针。我的工作流程如下。

1.) 创建显示卫星(世界风格)地图的 mapView。 2.) 在 ArcGIS Online 上从我的用户帐户添加公共 webMap 作为卫星地图上的叠加层/图层。

我尝试过的

//.h

#import <ArcGIS/ArcGIS.h>

@interface ViewController : UIViewController <AGSWebMapDelegate>

@property (strong, nonatomic) IBOutlet AGSMapView *mapView;

//.m

// Add basemap

NSURL* url = [NSURL URLWithString:@"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"];
AGSTiledMapServiceLayer *tiledLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:url];
[self.mapView addMapLayer:tiledLayer withName:@"Basemap Tiled Layer"];

//If I run this part alone, I'll get the satellite map.


AGSWebMap* webmap = [[AGSWebMap alloc] initWithItemId:@"bb9b8c172e8142f995526bf658078f54" credential:nil];
webmap.delegate = self;
[webmap openIntoMapView:self.mapView];

//When I add this webMap code and run the project, I get a blank white screen.


//.m cont.

- (void)mapViewDidLoad:(AGSMapView *) mapView {
NSLog(@"mapView didLoad");    
}

- (void) webMapDidLoad:(AGSWebMap*) webMap {
NSLog(@"webmap added successfully");
}

//Neither of these logs get called.

问题。

1.) 使用 AGSTiledMapServiceLayer 作为我的底图是否正确?另外,我的 ArcGIS Online 地图使用 AGSWebMap 是否正确?

2.) 我的目标是能够在卫星底图中添加和删除多个图层,一次一个。我在正确的轨道上吗?

我目前正在使用 MapBox 来实现这一点,但我开始尝试使用 ArcGIS SDK 及其功能。

提前致谢。

【问题讨论】:

  • 查看 ObjC 代码的答案。我认为通过在基本地图上更新 Web 地图是正确的做法。

标签: ios objective-c arcgis


【解决方案1】:

你快到了。确保所有这 3 个项目都在适当的速度。

来自https://developers.arcgis.com/ios/objective-c/guide/viewing-web-map.htm的讨论。

在您之前拨打电话的地方拨打电话(大概是viewDidLoad

  • 实例化一个 AGSWebMap 对象 // 1
  • 然后必须将您的类的一个实例设置为 web 地图的委托 // 2

    // 1
    AGSWebMap* webmap = [[AGSWebMap alloc] initWithItemId:@"bb9b8c172e8142f995526bf658078f54" credential:nil];
    // 2
    webmap.delegate = self;
    

然后更新处理程序webMapDidLoad() // 3

  // open the web map into a map view in the delegate handler
- (void) webMapDidLoad:(AGSWebMap*) webMap {
    // 3
    [webmap openIntoMapView:self.mapView];  
    NSLog(@"webmap added successfully");
}

【讨论】:

    猜你喜欢
    • 2021-07-17
    • 2016-11-23
    • 2019-05-05
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 2020-08-08
    • 1970-01-01
    相关资源
    最近更新 更多