From the previous announcement
In this post will go over the interesting parts of the code for advance users. At the 2012 User Conference Lauren Rosenshein Bennett gave a Geoprocessing presentation in which she demonstrated an iPad application. The source code for this app is now available from GitHub!
Spatial analysis everywhere – iPad mobile device to collect points and then run the GP service to recalculate the results. The application was developed to be used at the User Conference 2012 plenary.
The demo was developed for the iPad using the ArcGIS Runtime SDK for iOS 2.3, xCode 4.4 (with Automatic Reference Counting), iOS 5.1. The charts were developed using the open source library CorePlot for iOS http://code.google.com/p/core-plot/
The application is map centric, which means it is using one View to add the surface of the map and buttons as images. The heavy lifting of the application is provided by geoprocessing.
When the application starts it calls the controller ViewDidLoad method where we initialize the map, including all the layers needed for the application, sets the initial extent and any gesture recognizer we need. When adding a map layer, the method returns a UIView that is added into the parent view. This view will be used to compare against other views. In essence we will be comparing views and transforming them within the UI to produce a good user experience.
The application includes a unique swipe gesture. The slider allows the user to compare 2 layers of the map. Thanks to Eric Ito from the iOS/OSX development team who created the logic for this. http://video.esri.com/watch/1141/developing-applications-on-mac-os
The Gesture control will add the image of the view on top of the map and when the slider is used the picture on top gets cropped on the right hand side, giving a smooth user experience showing the previous map underneath. All this is possible by using the built in transformations depending on the finger position.
This control allows the user to slide with one finger to compare 2 layers.
For the slider and to give the impression the user is moving it, we position the control on the fingers position using a CGAffileTransform on the control.
When the user lifts their finger, the top image will be removed and the slider will animate back to the initial position.
The ArcGIS Runtime SDK for iOS Sketch layer is used to change values in the geoprocessing task. The user can add points by clicking the map and enter attributes for the graphics created.
To change the attributes, we display a form that allows only one attribute change on the graphic, and then adds the graphic to the feature layer.
Geoprocessing
Consuming geoprocessing task in the ArcGIS Runtime SDK for iOS is simple, the process runs on the ArcGIS server and the client consumes the results.
The geoprocess api requires a url and the parameters to pass. Geoprocesses can run asynchronous (execute) or synchronous (submit job). Using the AGSGeoprocessorDelegate will return the result of the task.
When successful, a map service will be returned.
This is just a demo application with a few controls that can be used and extended. We encourage cloning or forking the repository. The geoprocessing services are hosted on a demo servers that may not be up and running 24/7 nor optimized for heavy traffic.
You can find the source code at GitHub
Happy forking!