Is there anyone can help me on WMTS services accessing problem with ArcGIS iOS SDK?

06-29-2013 02:28 AM
New Contributor
I have downloaded the latest ArcGIS iOS SDK and i was trying to modify the demo to access a WMTS service, my code is posted as below:
- (void)viewDidLoad {
    [super viewDidLoad];
 // set the delegate for the map view
 self.mapView.layerDelegate = self;
 //create an instance of a tiled map service layer
// AGSTiledMapServiceLayer *tiledLayer = [[AGSTiledMapServiceLayer alloc] initWithURL:[NSURL URLWithString:kTiledMapServiceURL]];
// //Add it to the map view
// [self.mapView addMapLayer:tiledLayer withName:@"Tiled Layer"];
    wmtsSrv = [[AGSWMTSInfo alloc] initWithURL:[NSURL URLWithString:kWMTSMapServiceURL]];
    wmtsSrv.delegate = self;

 //release to avoid memory leaks
 //create an instance of a dynmaic map layer
// self.dynamicLayer = [[AGSDynamicMapServiceLayer alloc] initWithURL:[NSURL URLWithString:kDynamicMapServiceURL]];
// //set visible layers
// self.dynamicLayer.visibleLayers = [NSArray arrayWithObjects:[NSNumber numberWithInt:2], nil];
// //name the layer. This is the name that is displayed if there was a property page, tocs, etc...
// [self.mapView addMapLayer:self.dynamicLayer withName:@"Dynamic Layer"];
// //set transparency
// self.dynamicLayer.opacity = 0.2;

- (void)wmtsInfoDidLoad:(AGSWMTSInfo *)wmtsInfo
    AGSWMTSLayerInfo *wmtsLayerInfo = [wmtsInfo.layerInfos objectAtIndex:0];
    wmtsLayerInfo.tileMatrixSet = @"TileMatrixSet_0";
    AGSSpatialReference *spatialRef = [[AGSSpatialReference alloc] initWithWKID:4326];
    AGSWMTSLayer *wmtsLayer = [wmtsInfo wmtsLayerWithLayerInfo:wmtsLayerInfo andSpatialReference:spatialRef];
    [self.mapView addMapLayer:wmtsLayer withName:@"WMTS Layer"];

after running the code above, i can only see the grid view without any tile images, so is there anyone can help me on this?

Thanks in advance!!
0 Kudos
2 Replies
New Contributor
sorry, i forgot the url of the wmts service,
here it is
0 Kudos
Esri Regular Contributor
Hi Wei Chen,

I couldn't test the URL you provided, but out of curiosity, what is the spatial reference of the WMTS layer?

Here are some code snippets that I used to load an AGSWMTSLayer:

#import <UIKit/UIKit.h>
#import <ArcGIS/ArcGIS.h>

#define wmtsURL @"http://....../wmts"

@interface ViewController : UIViewController <AGSMapViewLayerDelegate, AGSWMTSInfoDelegate> {
    //container for map layers
AGSMapView *_mapView;

//map view is an outlet, can associate with UIView
@property (strong, nonatomic) IBOutlet AGSMapView *mapView;
//add the WMTS properties...
@property (strong, nonatomic) AGSWMTSInfo *wmtsInfo;
@property (strong, nonatomic) AGSWMTSLayer *wmtsLayer;


#import "WMTSViewController.h"
@implementation ViewController
@synthesize mapView = _mapView;

- (void)viewDidLoad
    [super viewDidLoad];
    self.mapView.layerDelegate = self;
    self.wmtsInfo = [[AGSWMTSInfo alloc] initWithURL: [NSURL URLWithString:wmtsURL]];
    self.wmtsInfo.delegate = self;

// add AGSWMTSLayer
- (void) wmtsInfoDidLoad:(AGSWMTSInfo *) wmtsInfo{
    NSArray *layerInfos = [wmtsInfo layerInfos];
    AGSWMTSLayerInfo *layerInfo = [layerInfos objectAtIndex:0];
    self.wmtsLayer = [wmtsInfo wmtsLayerWithLayerInfo:layerInfo andSpatialReference:nil];
    [self.mapView addMapLayer:self.wmtsLayer withName:@"wmts Layer"];

//other functions, etc.

Hope this helps!
0 Kudos