self.incidentsLayer = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:@"http://egisws02.nos.noaa.gov/ArcGIS/rest/services/MP/MPA_Inventory_Fishing/MapServer/1"] mode:AGSFeatureLayerModeOnDemand]; self.incidentsLayer.outFields = [NSArray arrayWithObject:@"*"]; self.incidentsLayer.infoTemplateDelegate = self.incidentsLayer; self.restrictedLayer = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:@"http://egisws02.nos.noaa.gov/ArcGIS/rest/services/MP/MPA_Inventory_Fishing/MapServer/2"] mode:AGSFeatureLayerModeOnDemand]; self.restrictedLayer.outFields = [NSArray arrayWithObject:@"*"]; self.restrictedLayer.infoTemplateDelegate = self.restrictedLayer; [self.mapView addMapLayer:self.incidentsLayer withName:@"Incidents"]; [self.mapView addMapLayer:self.incidentsLayer withName:@"Restricted"];
Solved! Go to Solution.
#import "RelatedRecordEditingSampleViewController.h"
#import <ArcGIS/ArcGIS.h>
#import "NotesViewController.h"
#import "LoadingView.h"
//this is the url for the basemap.
#define kBaseMapServiceURL @"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
//url for the incidents layer
#define kIncidentsLayerURL @"http://egisws02.nos.noaa.gov/ArcGIS/rest/services/MPA/MPA_Inventory_Fishing/MapServer/1"
#pragma mark - Class Extension
@interface RelatedRecordEditingSampleViewController()
@property (nonatomic, retain) IBOutlet AGSMapView *mapView;
@property (nonatomic, retain) AGSFeatureLayer *incidentsLayer;
@property (nonatomic, retain) AGSFeatureLayer *restrictedLayer;
@property (nonatomic, retain) AGSPopupsContainerViewController* popupVC;
@property (nonatomic, retain) UIBarButtonItem* customActionButton;
@property (nonatomic, retain) LoadingView* loadingView;
@end
#pragma mark - Implementation
@implementation RelatedRecordEditingSampleViewController
@synthesize mapView = _mapView;
@synthesize incidentsLayer = _incidentsLayer;
@synthesize popupVC = _popupVC;
@synthesize loadingView = _loadingView;
@synthesize customActionButton = _customActionButton;
@synthesize restrictedLayer = _restrictedLayer;
#pragma mark - UIView methods
- (void)viewDidLoad {
//creating a tiled service with the base map url
NSURL *mapUrl = [NSURL URLWithString:kBaseMapServiceURL];
AGSTiledMapServiceLayer *tiledLyr = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:mapUrl];
//add the tiled layer to the map view
[self.mapView addMapLayer:tiledLyr withName:@"Tiled Layer"];
//Zooming to an initial envelope with the specified spatial reference of the map.
//this is the San Francisco extent.
AGSSpatialReference *sr = [AGSSpatialReference spatialReferenceWithWKID:102100];
AGSEnvelope *env = [AGSEnvelope envelopeWithXmin:-13639984
ymin:4537387
xmax:-13606734
ymax:4558866
spatialReference:sr];
[self.mapView zoomToEnvelope:env animated:YES];
//Set up the map view
self.mapView.calloutDelegate = self;
//setup the incidents layer as a feature layer and add it to the map
self.incidentsLayer = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:kIncidentsLayerURL] mode:AGSFeatureLayerModeOnDemand];
self.incidentsLayer.outFields = [NSArray arrayWithObject:@"*"];
self.incidentsLayer.infoTemplateDelegate = self.incidentsLayer;
self.restrictedLayer = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:@"http://egisws02.nos.noaa.gov/ArcGIS/rest/services/MP/MPA_Inventory_Fishing/MapServer/7"] mode:AGSFeatureLayerModeOnDemand];
self.restrictedLayer.outFields = [NSArray arrayWithObject:@"*"];
self.restrictedLayer.infoTemplateDelegate = self.restrictedLayer;
[self.mapView addMapLayer:self.incidentsLayer withName:@"Incidents"];
[self.mapView addMapLayer:self.restrictedLayer withName:@"Restrictions"];
//setting the custom action button which will be later used to display related notes of an incident
// self.customActionButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"pencil.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(displayIncidentNotes)] autorelease];
[super viewDidLoad];
}