2. Create an app of the Halifax region using an
Esri basemap
Use feature layers to display data which can
be turned on/off
Ability to query data
Find optimal routing between locations
Initial Project Plan
Image from: https://weather.gc.ca/forecast/canada/index_e.html?id=NS
4. Getting Started
Choose an Android Version and API level
Create an emulator
Basics of Android Studio
Esri tutorials from ArcGIS for Developers
5. Android Platform Versions
Platform versions are a trade off between the
percentage of users’ the app aims to target
and available features.
6. Creating an Emulator
Option to connect an Android device or use a virtual emulator
We created several emulators in Android Studio which are shown in the
image below
7. Basics of Android Studio
Build Automation
Gradle has the ability to access
other host repositories including
Maven
Android studio is the only IDE that
supports the Gradle build system
8. Tutorial 1: Add a map to your app
Completed the ‘Add a map to your app’ tutorial on the Esri developers website
Defined MapView
Problems:
9. Tutorial 2: Use ArcGIS basemaps (1/2)
In the onCreate method, the mapView was retrieved from
the XML where we defined it earlier
onPause and onResume methods were added
In menu_main.xml 4 different basemaps were defined as a
menu item
10. Several basemap variables were defined
In the onCreateOptionsMenu method, menu.getItem
was used to retrieve the basemap menu items
onOptionsItemSelected uses the menu item ID to
determine the action to be taken from the switch
statement
Tutorial 2: Use ArcGIS basemaps (2/2)
11. Tutorial 3: Access feature data in the cloud
A Feature layer URL was added to the string.xml, this accesses the layer from
the cloud
Layer variables were defined in main code
Code was added to the onCreate method to create the feature layer graphic
upon start up
12. Tutorial 4: Add geocoding to your app
Geocoding variables were added
New graphics layer was added in the onCreate method
Code was added to set a listener to ensure that the map view was
initialized and ready to use upon app startup.
The next step was to allow user to enter an address this was done by
adding a search button to the top bar in the app.
LocatorAsyncTask method added to execute the geocoding and zoom to
the specified location.
13. Creating the Layers Used
Trails
Provided by Halifax Open Data (http://www.halifax.ca/opendata/) and imported into ArcGIS
Online
Breweries
Geocoded using ArcGIS Online
Shopping Centres
Main large shopping centres were chosen
Geocoded using ArcGIS Online
Parks
Provincial parks within Halifax County were located from http://parks.novascotia.ca/
Geocoded using ArcGIS Online
Hospitals
Geocoded using ArcGIS Online
All layers were symbolized within ArcGIS Online, and made available to the public
14. Geocoding in ArcGIS Online
CSV files were created using
Addresses of the locations used.
They were then imported into ArcGIS
Online which automatically geocoded
the locations.
15. Trails Layer
Layer was downloaded from Halifax Open
Data website
(http://www.halifax.ca/opendata/) as a
shapefile and imported into ArcGIS for
Desktop.
Problem: Projection
Web Mercator
The layer is then shared as a feature service
and brought into ArcGIS Online.
All feature layers were added in the
string.xml file using the feature service URL’s
16. Creating Image Buttons
Image Buttons were created to allow user to
query or select feature layers
Five image buttons were used: App Info,
Brewery, Biking (Trails), Parks and Shopping
Centres.
A drawable xml was created for each button
that defined the shape and color of the button.
The ImageButtons were created under the
layout folder with the drawable and mipmap
photos assigned as part of their attributes
The onClick attribute was used to link the
button to a method within the code that
defined the button’s action.
17. Using the App Info Button
When information button is clicked the method appInfo is called that displays a
pop up window explaining the app to the user.
18. Using the Brewery Button
When the brewery button is clicked the onBreweryClick method is called
This method uses a boolean to track whether the layer is turned on or off.
For example if the layer is turned on, pressing the button will turn the layer off
and vice versa.
Brewery layer was added as a feature layer using the feature layer URL
19. Using the Trail (Biking) Button
The trail layer is defined in the onCreate method and is displayed upon start up.
When the user clicks on the biking button it calls the showPopup method.
When the user makes their selection it calls the onMenuItemClick method.
Resulting trails are highlighted in blue using a SimpeLineSymbol
20. Using the Park button
The park layer is defined in the onCreate method and is displayed upon
start up
This button works similarly to the biking button, where it queries the
layers attributes allowing the user to select parks where there is
swimming permitted.
The button calls the showPopupPark method to inflate the park menu
Parks are identified by an overlaying SimpleMarkerSymbol
21. Using the Shopping Button
When the shopping button is clicked the onShoppingClick method is called. The
button calls the showPopupPark method to inflate the park menu
Similar to the brewery button, this method uses a Boolean to track whether the
layer is turned on or off
For example is the layer is turned on, presses the button will turn the layer off and
vice versa
Shopping Centre's are shown with blue shopping bag symbols
22. Using the Hospital Menu
When the hospital button is clicked on the top tool bar the hospital menu is
inflated using the showPopupHospital method.
When a hospital is chosen from the menu, the onMenuItemClick method is
called which queries the chosen hospital based on it’s attributes.
This results in a red cross graphic overlaying the hospital the user selected
23. Other Problems
Android Studio frequent updates
Downloaded projects from GitHub would not sync (Routing)
Creating multiple menus
Main activity is doing too much work
We created an AlertDialog builder. This allows the user to close the popup window when they wish.
The other option was to use the toast option. But a specific amount of time coujld not be chosen (only short and long), and we did not know the speed of the reader
Problem: initial problem was that the when the layer was turned on, the button disappeared