Skip to content

Commit

Permalink
January 2019 release (v2019.01) (#166)
Browse files Browse the repository at this point in the history
* Updated Java exercises to Runtime 100.4.0 (#152)

Resolved #150

* Added KML (#154)

Part of #153

* Added README and navigation (#155)

Resolves #116

* Updated ArcGIS Runtime in Android exercises (#162)

Resolves #156

* Added KML to Android (#163)

#153

* Qt: updated Runtime, added KML (#164)

- Part of #153
- Resolved #157
  • Loading branch information
Gary Sheppard authored Jan 26, 2019
1 parent 091eedf commit 286bc76
Show file tree
Hide file tree
Showing 68 changed files with 768 additions and 287 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# GeoDev D.C. Labs
Lab exercises for Esri GeoDev events held in the Washington, D.C., area.

These lab exercises were developed for Esri GeoDev events held in the Washington, D.C., area. They are available for anyone who wants to get to know ArcGIS Runtime using step-by-step tutorial-style exercises in a variety of development platforms.

Do you want to go step by step? [Go to the exercises.](runtime-workshop/exercises/README.md)

Do you want to cut to the chase and see the code? [Go to the solutions.](runtime-workshop/solutions)

## Licensing

Copyright 2016-2018 Esri
Copyright 2016-2019 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ If you need some help, you can refer to [the solution to this exercise](../../so
## Add ArcGIS Runtime to the app
1. In your Android Studio project, under **Gradle Scripts**, there are two files called `build.gradle`: one for the **project** and one for the **app module**. Open `build.gradle` for your project. Under `allprojects` > `repositories`, add a reference to the Esri Maven repository on Bintray. Make sure you do this under `allprojects` and not under `buildscript`:
1. In your Android Studio project, under **Gradle Scripts**, there are two files called `build.gradle`: one for the **project** and one for the **app module**. Open `build.gradle` for your project. Under `allprojects` > `repositories`, add a reference to the Esri Maven repository on Bintray, as well as the Google repository. Make sure you do this under `allprojects` and not under `buildscript`:
```
allprojects {
repositories {
jcenter()
// Add the next three lines
// Add the next lines
google()
maven {
url 'https://esri.bintray.com/arcgis'
}
Expand All @@ -61,7 +62,7 @@ If you need some help, you can refer to [the solution to this exercise](../../so
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
// Add the next line
implementation 'com.esri.arcgisruntime:arcgis-android:100.2.1'
implementation 'com.esri.arcgisruntime:arcgis-android:100.4.0'
}
```
Expand Down
44 changes: 32 additions & 12 deletions runtime-workshop/exercises/Android/Exercise 3 Operational Layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This exercise walks you through the following:
- Add a layer from a mobile map package to the 2D map
- Add a scene layer to the 3D scene
- Add a KML layer to the 2D map and 3D scene

Prerequisites:
- Complete [Exercise 2](Exercise%202%20Zoom%20Buttons.md), or get the Exercise 2 code solution compiling and running properly, preferably in an IDE.
Expand All @@ -23,14 +24,6 @@ ArcGIS Runtime provides a variety of ways to add **operational layers** to the m
1. In Android 6 (API level 23) and higher, in addition to the `uses-permission` element, a production app should include Java code to [request permissions at runtime](https://developer.android.com/training/permissions/requesting.html). You could instead go to **Settings > Apps > <your app> > Permissions** on your Android device and grant the **Storage** permission manually, but that permission sometimes gets wiped out when you reinstall the app during development, which becomes very inconvenient. Therefore, here we will take the time to request permissions at runtime.
First, open your project's `build.gradle` file where you added a reference to the Esri Bintray Maven repository. Add a reference to Google's Maven repository:
```
maven {
url 'https://maven.google.com'
}
```
Open the app's `build.gradle` file where you added a reference to the ArcGIS Runtime Android library. Add a reference to the Android Support Library `v4` library:
```
Expand Down Expand Up @@ -151,18 +144,18 @@ ArcGIS Runtime provides a variety of ways to add **operational layers** to the m
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. Scene layers can be viewed in a variety of ArcGIS clients, including ArcGIS Runtime. Here you will add a scene layer to your 3D scene.
1. Declare a constant value to specify the URL of a scene service. You can use a `SceneServer` URL or an ArcGIS Online or Portal for ArcGIS item URL that represents a scene service. The following URL shows plain gray buildings in Washington, D.C.:
1. Declare a constant value to specify the URL of a scene service. You can use a `SceneServer` URL or an ArcGIS Online or Portal for ArcGIS item URL that represents a scene service. The following URL shows buildings in San Francisco:
```
private static final String SCENE_SERVICE_URL =
"https://www.arcgis.com/home/item.html?id=606596bae9e44394b42621e099ba392a";
"https://www.arcgis.com/home/item.html?id=943d302fd85b4b6dbd35f399cfb9a4a8";
```
The following URL shows photo-realistic buildings in Philadelphia:
```
private static final String SCENE_SERVICE_URL =
"https://www.arcgis.com/home/item.html?id=a7419641a50e412c980cf242c29aa3c0";
"https://www.arcgis.com/home/item.html?id=2c9286dfc69349408764e09022b1f52e";
```
1. In Exercise 1, you added code to set up the scene with a basemap and an elevation source. After that code, in the same block, create a new `final ArcGISSceneLayer` based on the scene service, give the layer an event handler for when it is done loading, and add the layer to the scene:
Expand Down Expand Up @@ -198,11 +191,38 @@ Web scene layers are cached web layers that are optimized for displaying a large
1. Compile and run your app. Verify that when you switch to 3D, the 3D features display and the view is rotated and pitched.
## Add a KML layer to the 2D map and 3D scene
Most organizations use a mix of ArcGIS and non-ArcGIS data formats. Many organizations distribute mapping data in the Keyhole Markup Language (KML) format. Here you will use a KML URL to add a layer to your 2D map and 3D scene.
1. Declare a constant value to specify the URL of a KML file or network link. The following URL shows earthquakes of magnitude 1.0 or greater in the past seven days, colored by age:
```
private static final String KML_URL =
"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_week_age_link.kml";
```
1. You added a listener to the mobile map package to set up the map after the mobile map package loads. In that listener, after setting the map and the basemap, create a KML layer and add it to the map:
```
KmlLayer kmlLayer = new KmlLayer(new KmlDataset(KML_URL));
map.getOperationalLayers().add(kmlLayer);
```
1. You added a scene layer to the scene. After that, create a KML layer and add it to the scene:
```
KmlLayer kmlLayer = new KmlLayer(new KmlDataset(KML_URL));
scene.getOperationalLayers().add(kmlLayer);
```
1. Compile and run your app. Zoom out and verify that the earthquake dots appear on the 2D map. Switch to 3D and verify that the earthquake dots appear on the 3D scene.
## How did it go?
If you have trouble, **refer to the solution code**, which is linked near the beginning of this exercise. You can also **submit an issue** in this repo to ask a question or report a problem. If you are participating live with Esri presenters, feel free to **ask a question** of the presenters.
If you completed the exercise, congratulations! You learned how to add a local feature layer from a mobile map package to a map.
If you completed the exercise, congratulations! You learned how to add a local feature layer from a mobile map package to a map. You also learned how to add KML to a 2D map and a 3D scene.
Ready for more? Choose from the following:
Expand Down
7 changes: 7 additions & 0 deletions runtime-workshop/exercises/Android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Android exercises

- [Exercise 1: Map and Scene](Exercise%201%20Map%20and%20Scene.md)
- [Exercise 2: Add Zoom In and Zoom Out Buttons](Exercise%202%20Zoom%20Buttons.md)
- [Exercise 3: Add Operational Layers](Exercise%203%20Operational%20Layers.md)
- [Exercise 4: Buffer a Point and Query Features](Exercise%204%20Buffer%20and%20Query.md)
- [Exercise 5: Routing](Exercise%205%20Routing.md)
7 changes: 7 additions & 0 deletions runtime-workshop/exercises/AppStudio_QTQML/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# AppStudio for ArcGIS (QML) exercises

- [Exercise 1: Map](Exercise%201%20Map.md)
- [Exercise 2: Add Zoom In, and Zoom Out, and Location Buttons](Exercise%202%20Zoom%20Buttons.md)
- [Exercise 3: Add a Feature Service](Exercise%203%20Add%20Feature%20Service.md)
- [Exercise 4: Buffer a Point and Query Features](Exercise%204%20Buffer%20and%20Query.md)
- [Exercise 5: Service Area](Exercise%205%20ServiceArea.md)
52 changes: 44 additions & 8 deletions runtime-workshop/exercises/Java/Exercise 1 Map and Scene.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This exercise walks you through the following:
- Add a 3D scene to the app, and use a toggle button to switch between 2D and 3D

Prerequisites:
- Install the Java Development Kit (JDK) version 8 or higher.
- Install the Java Development Kit (JDK) version 11 or higher.
- Optional: install a Java integrated development environment (IDE).

If you need some help, you can refer to [the solution to this exercise](../../solutions/Java/Ex1_MapAndScene), available in this repository.
Expand All @@ -26,6 +26,16 @@ If you need some help, you can refer to [the solution to this exercise](../../so
}
```
**Note:** In recent Java releases, the JDK no longer includes JavaFX, so you will probably need to add a JavaFX dependency to your new project. In Maven, this is done as follows inside `pom.xml`'s `<dependencies>` element (which you should create if it does not yet exist):
```
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.1</version>
</dependency>
```
1. Instantiate a field of type `AnchorPane` that will hold the app's UI components:
```
Expand Down Expand Up @@ -75,14 +85,30 @@ If you need some help, you can refer to [the solution to this exercise](../../so
launch(args);
}
```
1. In newer versions of Java, you will probably get the following error if you run the app right now:
>Error: JavaFX runtime components are missing, and are required to run this application
Solve this error by creating a new class with a `main` method and having it call your app class's `main` method, and run this new class instead of your app class ([more info](https://stackoverflow.com/a/52654791/720773)):
```
public class Launcher {
public static void main(String[] args) {
WorkshopApp.main(args);
}
}
```
1. Compile and run your app. Verify that a button appears in the lower-right corner of the app:
![Blank app with button](01-blank-app-with-button.png)
## Add ArcGIS Runtime to the app
You have three options for adding ArcGIS Runtime 100.2.1 to your Java application project. Choose one of the following:
You have three options for adding ArcGIS Runtime to your Java application project. Choose one of the following:
1. **Use Gradle**: you can use Gradle if you started the exercise by creating a Gradle project. Open `build.gradle` and add ArcGIS dependencies. See [Develop your first map app with Gradle](https://developers.arcgis.com/java/latest/guide/develop-your-first-map-app-with-gradle.htm) for details.
Expand All @@ -96,7 +122,7 @@ You have three options for adding ArcGIS Runtime 100.2.1 to your Java applicatio
dependencies { classpath 'com.esri.arcgisruntime:gradle-arcgis-java-plugin:1.0.0' }
}
arcgis.version = '100.2.1'
arcgis.version = '100.4.0'
// download javadoc
eclipse.classpath.downloadJavadoc = true
Expand All @@ -123,8 +149,18 @@ You have three options for adding ArcGIS Runtime 100.2.1 to your Java applicatio
<dependency>
<groupId>com.esri.arcgisruntime</groupId>
<artifactId>arcgis-java</artifactId>
<version>100.2.1</version>
<version>100.4.0</version>
</dependency>
<!-- Add an execution element to have ArcGIS Runtime
automatically downloaded during the compile phase. -->
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>arcgis</goal>
</goals>
</execution>
</executions>
</dependencies>
<build>
Expand All @@ -134,16 +170,16 @@ You have three options for adding ArcGIS Runtime 100.2.1 to your Java applicatio
<artifactId>arcgis-java-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<version>100.2.1</version>
<version>100.4.0</version>
</configuration>
</plugin>
</plugins>
</build>
```
**Note:** Maven downloads the ArcGIS Runtime install to `<user home>/.arcgis`. ArcGIS Runtime tries to find it there, but that can fail under certain conditions. If it fails, you can go inside that install directory and copy the `jniLibs` and `resources` directories to your app's working directory.
**Note:** Maven downloads the ArcGIS Runtime install to `<user home>/.arcgis`. ArcGIS Runtime tries to find it there, but that can fail under certain conditions, especially with older ArcGIS Runtime releases. If it fails, you can go inside that install directory and copy the `jniLibs` and `resources` directories to your app's working directory.
3. **Use the downloaded ArcGIS Runtime SDK**: download the ArcGIS Runtime SDK (version 100.2.1) for Java and unzip it. In your Java project, reference the JAR files in the SDK's `libs` directory. You must also copy the SDK's `jniLibs` and `resources` directories to your Java project directory. (There are other ways of referencing ArcGIS Runtime, but copying `jniLibs` and `resources` is the simplest.) See [Develop your first map app using the downloaded SDK](https://developers.arcgis.com/java/latest/guide/develop-your-first-map-app.htm) for details.
3. **Use the downloaded ArcGIS Runtime SDK**: download the ArcGIS Runtime SDK for Java and unzip it. In your Java project, reference the JAR files in the SDK's `libs` directory. You must also copy the SDK's `jniLibs` and `resources` directories to your Java project directory. (There are other ways of referencing ArcGIS Runtime, but copying `jniLibs` and `resources` is the simplest.) See [Develop your first map app using the downloaded SDK](https://developers.arcgis.com/java/latest/guide/develop-your-first-map-app.htm) for details.
## Add a 2D map to the app
Expand Down
38 changes: 33 additions & 5 deletions runtime-workshop/exercises/Java/Exercise 3 Operational Layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This exercise walks you through the following:
- Add a layer from a mobile map package to the 2D map
- Add a scene layer to the 3D scene
- Add a KML layer to the 2D map and 3D scene

Prerequisites:
- Complete [Exercise 2](Exercise%202%20Zoom%20Buttons.md), or get the Exercise 2 code solution compiling and running properly, preferably in an IDE.
Expand Down Expand Up @@ -50,18 +51,18 @@ ArcGIS Runtime provides a variety of ways to add **operational layers** to the m
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. Scene layers can be viewed in a variety of ArcGIS clients, including ArcGIS Runtime. Here you will add a scene layer to your 3D scene.
1. Declare a constant value to specify the URL of a scene service. You can use a `SceneServer` URL or an ArcGIS Online or Portal for ArcGIS item URL that represents a scene service. The following URL shows plain gray buildings in Washington, D.C.:
1. Declare a constant value to specify the URL of a scene service. You can use a `SceneServer` URL or an ArcGIS Online or Portal for ArcGIS item URL that represents a scene service. The following URL shows buildings in San Francisco:
```
private static final String SCENE_SERVICE_URL
= "https://www.arcgis.com/home/item.html?id=606596bae9e44394b42621e099ba392a";
= "https://www.arcgis.com/home/item.html?id=943d302fd85b4b6dbd35f399cfb9a4a8";
```
The following URL shows photo-realistic buildings in Philadelphia:
```
private static final String SCENE_SERVICE_URL
= "https://www.arcgis.com/home/item.html?id=a7419641a50e412c980cf242c29aa3c0";
= "https://www.arcgis.com/home/item.html?id=2c9286dfc69349408764e09022b1f52e";
```
1. In your 2D/3D toggle button event handler method, after you instantiate your `ArcGISScene`, set its basemap and surface, and instantiate your `SceneView`, create a new `ArcGISSceneLayer` based on the scene service, give the layer an event handler for when it is done loading, and add the layer to the scene:
Expand Down Expand Up @@ -97,12 +98,39 @@ Web scene layers are cached web layers that are optimized for displaying a large
1. Compile and run your app. Verify that when you switch to 3D, the 3D features display and the view is rotated and pitched. Also try the built-in 3D navigation by holding the right mouse button and moving the mouse:
![3D scene pitched and rotated](07-scene-layer-rotated.jpg)
## Add a KML layer to the 2D map and 3D scene
Most organizations use a mix of ArcGIS and non-ArcGIS data formats. Many organizations distribute mapping data in the Keyhole Markup Language (KML) format. Here you will use a KML URL to add a layer to your 2D map and 3D scene.
1. Declare a constant value to specify the URL of a KML file or network link. The following URL shows earthquakes of magnitude 1.0 or greater in the past seven days, colored by age:
```
private static final String KML_URL
= "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_week_age_link.kml";
```
1. You added a listener to the mobile map package to set up the map after the mobile map package loads. In that listener, after setting the map and the basemap, create a KML layer and add it to the map:
```
KmlLayer kmlLayer = new KmlLayer(new KmlDataset(KML_URL));
map.getOperationalLayers().add(kmlLayer);
```
1. In your 2D/3D toggle button handler, you added a scene layer to the scene. After that, create a KML layer and add it to the scene:
```
KmlLayer kmlLayer = new KmlLayer(new KmlDataset(KML_URL));
scene.getOperationalLayers().add(kmlLayer);
```
1. Compile and run your app. Zoom out and verify that the earthquake dots appear on the 2D map. Switch to 3D and verify that the earthquake dots appear on the 3D scene.
## How did it go?
If you have trouble, **refer to the solution code**, which is linked near the beginning of this exercise. You can also **submit an issue** in this repo to ask a question or report a problem. If you are participating live with Esri presenters, feel free to **ask a question** of the presenters.
If you completed the exercise, congratulations! You learned how to add a local feature layer from a mobile map package to a 2D map and a scene layer to a 3D scene.
If you completed the exercise, congratulations! You learned how to add a local feature layer from a mobile map package to a 2D map and a scene layer to a 3D scene. You also learned how to add KML to a 2D map and a 3D scene.
Ready for more? Choose from the following:
Expand Down
7 changes: 7 additions & 0 deletions runtime-workshop/exercises/Java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Java exercises

- [Exercise 1: Map and Scene](Exercise%201%20Map%20and%20Scene.md)
- [Exercise 2: Add Zoom In and Zoom Out Buttons](Exercise%202%20Zoom%20Buttons.md)
- [Exercise 3: Add Operational Layers](Exercise%203%20Operational%20Layers.md)
- [Exercise 4: Buffer a Point and Query Features](Exercise%204%20Buffer%20and%20Query.md)
- [Exercise 5: Routing](Exercise%205%20Routing.md)
Loading

0 comments on commit 286bc76

Please sign in to comment.