Agenda
• The ArcGIS System • Using the Runtime SDK for iOS
- Display Maps - Perform Analysis - Visualize Results
• Q&A
remember to turn in your surveys. Help make this session better,
ArcGIS - A Complete Geographic Information System
Author
Serve
Use
ArcGIS Server
ArcGIS Desktop
. . . For Authoring, Serving & Using Geographic Knowledge
Native Applications and Runtime SDKs
Configurable COTS applications and Native ArcGIS Runtime SDKs
iOS Android
Applications • ArcGIS
Windows Phone
Windows Mobile
Windows Linux
Runtime SDK • Objective C
Applications • ArcGIS
Runtime SDK • Java
Applications • ArcGIS
Runtime SDK • Silverlight
Applications • ArcGIS
Runtime SDK • .NET
Applications • ArcGIS Explorer*
Runtime SDK • WPF, Java
Applications • None
Runtime SDK • Qt, Java
ArcGIS Runtime SDK for iOS
• Build native applications using Objective-C - iPhone 3GS / 4 / 4S, iPod Touch, iPad 1 / 2 - Must be running iOS 4 or higher
Web or Native applications?
• ESRI supports both
• Advantages of native applications - Tighter integration with other native apps - Access to resources
- Contacts, calendar events, photos - Marketing/Hosting/Reporting via AppStore
• Disadvantages - Dedicated effort to write and maintain
Before you can begin..
• You need an Intel-based Mac running OSX 10.6 (Snow Leopard) or 10.7 (Lion)
• Join iOS Developer Program - Standard : AppStore distribution - Enterprise : In-House distribution
• Download iOS SDK (4.2.x)
& Xcode IDE (4.x)
Before you can begin..
• ArcGIS Runtime SDK for iOS
- v2.2 : Download from the Resource Center
• Conceptual Help
• API Reference
• Developer Samples
• Deployment
• User Forum
What you can do with the API
• Display maps
• Perform analysis
• Visualize results
• Collect data
• Access Online content - Using ArcGIS Portal REST API - New at v2.2
Displaying a Map
• UI Component AGSMapView
- Responds to gestures
- Displays device location, heading, and bearing
- Wrap-around dateline
Displaying a Map
• Add AGSMapView to the UI using Interface Builder
• Or, programmatically through code
Adding Content to AGSMapView
• Mashup basemap & operational layers
- ArcGIS Server, WMS - Bing, Open Street Map - Graphics - Local Tile Packages
//create the layer AGSLocalTiledLayer* myLayer = [AGSLocalTiledLayer localTiledLayerWithName:@"WildlifeHabitat"]; //add to map [self.mapView addMapLayer:myLayer withName:@”MyLayer1"];
Adding Content to AGSMapView
• Open web maps
- ArcGIS.com - Portal for ArcGIS
//create the web map AGSWebMap* webmap = [AGSWebMap webMap withItemId:@"e229d715f7ca4fa980308549fb288165" credential:nil]; //open into mapview [webmap openIntoMapView:self.mapView];
Respond to events through Delegates Map Delegates
• Layer Events
- Map loaded, failed to load - Layer loaded, failed to load
• Touch Events
- Tap, Tap and Hold - Move Tap and Hold
• Callout Events
- Did Show Callout, Should Show Callout - Did Click Accessory Button
Responding to Map Touch events 1. Adopt the Delegate protocol
@interface MyController: UIViewController <AGSMapViewTouchDelegate> { }
2. Implement the protocol methods
@implementation MyController - (void) mapView:(AGSMapView*) mapView didClickAtPoint:(CGPoint) screen mapPoint:(AGSPoint*) mappoint graphics:(NSDictionary*) graphics { //handle touch event }
3. Set Delegate
self.mapView.touchDelegate = self;
Performing Analysis Using Tasks
• Query, Find, Identify Task - Search for features In the map
• Geoprocessing Task
- Spatial analysis using GP tools and models
• Locator - Geocode and reverse geocode addresses
Performing Analysis Using Tasks (Contd.)
• Geometry Engine - native, high performance engine for performing
geometric operations on the device
• Network Analysis - Point-to-point and multipoint routes - Service Areas based on drive times - Closest facility for an incident
Common Pattern for using Tasks 1. Adopt the Task Delegate protocol
- (void)locator:(AGSLocator*)locator operation:(NSOperation*)op didFindLocationsForAddress:(NSArray*)candidates { //todo } - (void)locator:(AGSLocator*)locator operation:(NSOperation*)op didFailLocationsForAddress:(NSError*)error { //todo }
@interface MyController: UIViewController <AGSLocatorDelegate> { }
2. Implement the protocol methods
Common Pattern for using Tasks 3. Instantiate the task
self.locator = [AGSLocator locatorWithURL:[NSURL URLWithString:kGeoLocatorURL]];
4. Set Delegate
self.locator.delegate = self;
5. Perform operation
NSOperation* op = [self.locator locationsForAddress:addresses returnFields:outFields];
• Graphics Layer - Collection of Graphics
• Graphic = Geometry + Symbol
Polygon
Polyline
Point
Fill Line
Marker
Picture Text
Composite
Visualizing Results
Visualizing Results Contd.
• Graphic can optionally contain
- Attributes - Information about the graphic
- Info Template - Which attributes to display in a Callout
Visualizing Results Contd.
//create the symbol AGSPictureMarkerSymbol *marker = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"BluePushpin.png"]; //create the graphic AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:point symbol:marker attributes:dictionary //add the graphic to the graphics layer [self.graphicsLayer addGraphic:graphic];
Visualizing Results Contd.
• Callout - Displayed
when user taps on a graphic
• Content - Title & Detail - Image - Accessory button - Custom UI View
Specifying Content for the Callout 1. Adopt the Delegate Protocol
@interface MyController: UIViewController <AGSInfoTemplateDelegate> {
}
2. Implement the protocol methods
@implementation MyController - (NSString *) titleForGraphic:(AGSGraphic*)graphic screenPoint:(CGPoint)screen mapPoint:(AGSPoint*)map { //todo } - (NSString *) detailForGraphic:(AGSGraphic*)graphic screenPoint:(CGPoint)screen mapPoint:(AGSPoint*)map { //todo }
3. Set the delegate on the graphic
AGSGraphic *graphic = ... graphic.infoTemplateDelegate = self;
Responding to the Callout’s Accessory button
1. Adopt the Delegate Protocol
@interface MyController: UIViewController <AGSMapViewCalloutDelegate> { }
2. Implement the protocol methods
@implementation MyController - (void) mapView:(AGSMapView*) mapView didClickCalloutAccessoryButtonForGraphic:(AGSGraphic*) graphic { //todo }
3. Set the delegate
self.mapView.calloutDelegate = self;
Related Sessions
• Building Applications with ArcGIS Runtime SDK for iOS – Part II
- Today, 1 PM, Here
More Resources
• ArcGIS Resource Center - http://resources.arcgis.com - Conceptual help, API Reference - Samples, Blog, Forums
• Web Courses - http://training.esri.com - Getting Started with the ArcGIS API for iOS - Creating Data Collection Applications using ArcGIS API for
iOS
• Apple iOS Dev Center - http://developer.apple.com