Building Applications with ArcGIS Runtime SDK for ios - Part I Divesh Goyal Mark Dostal
Agenda The ArcGIS System Using the Runtime SDK for ios - Display Maps - Perform Analysis - Visualize Results Q&A Help make this session better, remember to turn in your surveys.
ArcGIS
ArcGIS - A Complete Geographic Information System Use Serve Author ArcGIS Server ArcGIS Desktop... For Authoring, Serving & Using Geographic Knowledge
ArcGIS for Web & Mobile Web APIs Flex JavaScript Silverlight REST Runtime SDKs ArcGIS Server
Native Applications and Runtime SDKs Configurable COTS applications and Native ArcGIS Runtime SDKs ios Android Windows Phone Windows Mobile Windows Linux Applications Applications Applications Applications Applications Applications ArcGIS ArcGIS ArcGIS ArcGIS ArcGIS Explorer* None Runtime SDK Runtime SDK Runtime SDK Runtime SDK Runtime SDK Runtime SDK Objective C Java Silverlight.NET WPF, Java Qt, Java
ArcGIS Runtime SDK for ios Formerly known as ArcGIS API for ios
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
Developing Applications
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
Built using the SDK
DEMO
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;
DEMO Displaying a map
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 @interface MyController: UIViewController <AGSLocatorDelegate> { } 2. Implement the protocol methods - (void)locator:(agslocator*)locator operation:(nsoperation*)op didfindlocationsforaddress:(nsarray*)candidates { //todo } - (void)locator:(agslocator*)locator operation:(nsoperation*)op didfaillocationsforaddress:(nserror*)error { //todo }
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];
Visualizing Results Graphics Layer - Collection of Graphics Graphic = Geometry + Symbol Polyline Line Point Polygon Marker Picture Fill Text Composite
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;
DEMO Using Tasks and Visualizing Results
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
Q&A Thank You Please fill out the surveys