- (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"];
}
//WMTSViewController.h
#import <UIKit/UIKit.h>
#import <ArcGIS/ArcGIS.h>
//URL of WMTS
#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;
@end
//WMTSViewController.m
#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.