ArcGIS Runtime SDK for Android - Recent...
Transcript of ArcGIS Runtime SDK for Android - Recent...
ArcGIS Runtime SDK for Android
Building Apps
Dan O’NeillRama Chintapalli
Agenda
• Introduction
• Developer Patterns
• Maps & Layers
• Geometry & Graphics
• Portal & Authentication
• Offline
• Geocoding and Routing
ArcGIS Android SDK
Introduction
Getting startedIn 5 minutes
Getting started with the SDK
1. Sign up for free Developers testing account
- 50 credits a month, premium content, register apps, test
tokens
2. Install Android Studio IDE
- https://developer.android.com/studio
3. Get dependencies automatically with Gradle and try it out
- Write an app!
New developers - Follow first map app
tutorial• Developers site > Android > Guide
- http://developers.arcgis.com/android/latest/guide
- Help topics
• Getting started > Develop your first map app
• Step-by-step guide
Existing developers - fork samples or example apps
• API samples
• Example apps
- Maps App
- Nearby
- Ecological Marine Units
GitHub Workflow• Fork
- The repo to have a local mirror of the repo
• Extending for your own use
- Use as a starting point to add specific features for your org
• Extend to contribute
- Create pull requests against your upstream to have your
contributions reviewed by the Example Apps team.https://esri.github.io/#Android
Gradle: Add AAR dependency
• Maven repository hosted by Bintray
- AARs, Version history
• Project build.gradle
repositories {
maven {
url 'https://esri.bintray.com/arcgis'
}
• App module build.gradle
dependencies {
compile 'com.esri.arcgisruntime:arcgis-android:100.0.0'
}
SDK resources• Developers site - http://developers.arcgis.com/android
- Doc – guide, API Reference
- Downloadable SDK
- Application support
• GitHub
- Samples - http://github.com/Esri/arcgis-runtime-samples-android
- Example apps
• GeoNet user community
- http://geonet.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-android
Stack Exchange #arcgis-android
Features
• Build apps for Android devices
• Visualize geographic data – maps, layers, graphics
- feature, dynamic, tiled, raster, …
• Identify features, query data, and display info pop-ups
• Share maps and content across ArcGIS platform
• Offline maps, data, routing, geocoding
• Powerful analysis and local geometric operations
• Loadable resources
• Async APIs using ListenableFutures
Dan
Developer Patterns
Loadable
• A pattern for classes that asynchronously load data
- Service calls, disk I/O, data processing…
- Layers, Map, Portal Items, Geodatabase, Tile Cache, Features etc
• Formalizes, enhances, and improves upon concepts that we had
before
- Provides a generic API across different types of classes
Loading
Failed To
LoadLoaded
Not
Loaded
Loadable pattern
• Loadable is async
- Specific pattern for load errors
- Has additional states
- Can reload if failed
- Supports chaining of loading
- Uses listeners
https://developers.arcgis.com/android/latest/guide/loadable-pattern.htm
Map Loaded
● LoadStatusChangedListener
● LoadStatusChanged
● Status
○ Loading
○ Not Loaded
○ Failed to Load
○ Loaded
ListenableFuture pattern
• Asynchronous methods use ListenableFuture
- A promise to return a result
- Add done listener, or call get (blocking)
• Can simplify asynchronous programming
- we take care of executing operations on
background threads
- standard pattern for errors
LocatorTask
● Future is a proxy or wrapper
around an object that is not
there yet
● geocodeFuture
○ Returns future
GeocodeResult
○ The promise that a
GeocodeResult will be
available in the future
○ Retrieve it with
geocodeFuture.get()
ListenableList pattern
• Bind to data
• Add Listener to know when content changes
• Implemented on
- Graphics in a GraphicsOverlay
- LayerList (operational, base, reference layers)
- Sublayers in SublayerList
- Bookmarks
Add Graphic to GraphicsOverlays
Dan
Maps & Layers
Map/MapView split
• MVC architecture
• Maps as a first class citizen
• GraphicsOverlay
MapView ArcGISMap
Layer
RasterLayer MapImageLayer TiledLayer
GraphicsOverlay
FeatureLayer
Map/MapView
• Content and presentation are separated
• ArcGISMap - separate class that defines content
- MapView references ArcGISMap
- Open a map, or build in code, modify, save
• MapView extends android.view.ViewGroup
- GraphicsOverlay(s), LocationDisplay, …
- Control visible extent of Map using Viewpoints
• Listenable lists of layers, bookmarks
Where Do Maps Come From?
• Portal (web maps)
- Create with a PortalItem or URL
• Pro (mobile maps)
- Access maps inside a Mobile Map Package
• You!
- Create a map in code
- Save to a portal
- Web maps and mobile maps will be different portal item types
- Save locally
Change Basemaps
DEMO
Rama
Geometries & Graphics
Geometry
• Immutable
• Has a spatial reference
• Can have z and m values
• Can be converted to/from Json
• Can create or modify with Builders
• Curves…
Geometry Builder - An Example
Geometry Operations
• Geometry Engine
- Buffer
- Clip
- Area
- GeodeticArea
- Project
- DistanceGeodetic
...more
Coordinate Conversion & Geographic Transformations in coming
releases
Graphics Overlay
• Temporary graphics added to MapView ONLY
• Contain List of Graphics
- Graphic (Attributes, symbol, geometry)
• Renderer
• Rendering mode
-Dynamic – better UX for display
-Static – good for lots of graphics
Map Sketching
DEMO
Rama
Portals & Authentication
AuthenticationManager & Authentication Challenge Handler
• Authentication Manager
- Manages user authentication for secured resources
- Central place for
- Setting an authentication handler
- Manage in-memory credential cache
- Manage OAuth Configuration
- Manage certificates
• AuthenticationChallengeHandler
• UX for challenge
• Credentials (http, token-based)
• PKI certificates
• Self signed certificates
DefaultAuthenticationChallengeHandler
exampleAuthenticationManager.setAuthenticationChallengeHandler(
new
DefaultAuthenticationChallengeHandler(context));
Security pattern – Oauth 2.0
• OAuthConfig
• Add to AuthenticationManager
• Use with DefaultAuthenticationChallengeHandler
• Also need to use DefaultOauthIntentReceiver
• Or use OAuthLoginManager directly
OAuthManager with default challenge
handler example
AuthenticationManager.setAuthenticationChallengeHandler(
new DefaultAuthenticationChallengeHandler(context));
OAuthConfiguration config = new OAuthConfiguration(
<Portal URL>, <Client ID>, <Redirect URI>);
AuthenticationManager.addOAuthConfiguration(config);
Portal API
• A developer’s gateway to the portal information model
• High-level, coarse-grained APIs to access, use, create, and share
content
• Key Classes
• Portal
• PortalUser
• PortalItem
• PortalGroup
Portal - Workflows• Search for content and groups
• Portal.findItemsAsync(portalQueryParams)
• Portal.findGroupsAsync(portalQueryParams)
• Add, modify, and share content
• PortalUser.addPortalItemAsync(item, params, folder)
• PortalItem.updateDataAsync(json)
• PortalItem.shareWithGroupsAsync(groups)
Portal - Workflows
• Access foundational content of a portal
• Basemaps
• Featured Groups
Portal - Workflows
• Access user’s content and groups
• PortalUser.fetchContentAsync()
• PortalUser.fetchContentInFolderAsync(folder)
• PortalUser.getGroups()
Authentication & Portal
DEMO
Dan & Rama
Offline
Offline Patterns - Create Offline Content
Desktop:
• Consume Mobile Map Packages
created in ArcGIS Pro
• Consume Runtime Content created
in ArcMap
• Best for single user
• Network datasets for offline routing
Service:
• Programmatic pattern to support
large number of users
• Can use map extent to select parts of
database to download to device
Mobile Map Packages
• Share maps and basemaps with mobile apps
• Consolidates into a single file (*.mmpk)
• Can be shared with organizational account
• Use cases include navigation and geocoding
- Custom locators
- Custom networks
Open MMPK
● Provide a path
● Loadable
● Get Maps
● Get descriptions
● Get Thumbnails
● Load Async
Open Mobile Map Package
DEMO
Service Pattern - Create Offline Content
• GeodatabaseSyncTask
- Can generate an offline geodatabase
- Can sync edits made to offline geodatabase
• ExportTileCacheTask
- Can generate a TileCache from a service
ExportTileCacheTask - Sample Code
GeodatabaseSyncTask - SampleCode
Dan
Geocoding & Routing
Geocoding API
LocatorTask
- Loadable
- Future - Promise
GeocodeResult
- List
Geocoding API
Display Results
- ListenableList
- Add Graphic to
GRaphicsOverlay
s
Routing API -
WorkflowRouteTask
- Loadable
- Future - Promise
RouteParameters
- List
- Get/Add Stops
SolveAsync
- RouteResult - List
Display
- Graphic from RouteResult
- Add to GraphicsOverlay
Geocode and Route
DEMO
Dan
Moving Forward
What’s coming
• Supporting the ArcGIS Platform
- Webmap layers
• Supporting 10.2.x equivalency issues (not all of them!)
- Image services
- Related tables
• Adding key new capabilities related to the ArcGIS Platform
- 3D on mobile
Agenda
• Introduction
• Developer Patterns
• Maps & Views
• Geometry & Graphics
• Portal & Authentication
• Offline
• Geocoding and Routing
Thank You