Skip to content

Commit a634741

Browse files
authored
Merge pull request #33 from ArcGIS/sample/find-route
Find route
2 parents ac7ba46 + b765508 commit a634741

31 files changed

+805
-0
lines changed

find-route/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

find-route/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Find route
2+
3+
Display directions for a route between two points.
4+
5+
![Image of find route](find-route.png)
6+
7+
## Use case
8+
9+
Find routes with driving directions between any number of locations. You might use the ArcGIS platform to create a custom network for routing on a private roads.
10+
11+
## How to use the sample
12+
13+
For simplicity, the sample comes loaded with a start and end stop. You can tap on the floating action button to display a route between these stops. Once the route is generated, turn-by-turn directions are shown in an expandable bottom sheet. Tap on a direction to zoom to that portion of the route.
14+
15+
## How it works
16+
17+
1. Set the `ArcGISEnvironment.applicationContext` to use a `RouteTask`
18+
2. Create a `RouteTask` using a URL to an online route service.
19+
3. Generate default `RouteParameters` using `routeTask.createDefaultParameters()`.
20+
4. Set `returnDirections` on the parameters to true.
21+
5. Add `Stop`s to the parameters `stops` collection for each destination.
22+
6. Solve the route using `routeTask.solveRoute(routeParameters)` to get a `RouteResult`.
23+
7. Iterate through the result's `Route`s. To display the route, create a graphic using the geometry from `route.routeGeometry`. To display directions, use `route.directionManeuvers`, and for each `DirectionManeuver`, display `DirectionManeuver.directionText`.
24+
25+
## Relevant API
26+
27+
* DirectionManeuver
28+
* Route
29+
* RouteParameters
30+
* RouteResult
31+
* RouteTask
32+
* Stop
33+
34+
## Tags
35+
36+
directions, driving, navigation, network, network analysis, route, routing, shortest path, turn-by-turn

find-route/README.metadata.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"category": "Routing and Logistics",
3+
"description": "Display directions for a route between two points.",
4+
"formal_name": "FindRoute",
5+
"ignore": false,
6+
"images": [
7+
"find-route.png"
8+
],
9+
"keywords": [
10+
"directions",
11+
"driving",
12+
"navigation",
13+
"network",
14+
"network analysis",
15+
"route",
16+
"routing",
17+
"shortest path",
18+
"turn-by-turn",
19+
"DirectionManeuver",
20+
"Route",
21+
"RouteParameters",
22+
"RouteResult",
23+
"RouteTask",
24+
"Stop"
25+
],
26+
"language": "kotlin",
27+
"redirect_from": [
28+
"/android/latest/sample-code/find-route.htm"
29+
],
30+
"relevant_apis": [
31+
"DirectionManeuver",
32+
"Route",
33+
"RouteParameters",
34+
"RouteResult",
35+
"RouteTask",
36+
"Stop"
37+
],
38+
"snippets": [
39+
"src/main/java/com/esri/arcgismaps/sample/findroute/MainActivity.kt"
40+
],
41+
"title": "Find route"
42+
}

find-route/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'org.jetbrains.kotlin.android'
3+
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
7+
defaultConfig {
8+
applicationId "com.esri.arcgismaps.sample.findroute"
9+
minSdkVersion rootProject.ext.minSdkVersion
10+
targetSdkVersion rootProject.ext.targetSdkVersion
11+
versionCode rootProject.ext.versionCode
12+
versionName rootProject.ext.versionName
13+
buildConfigField("String", "API_KEY", API_KEY)
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
23+
buildFeatures {
24+
dataBinding true
25+
}
26+
}
27+
28+
dependencies {
29+
// lib dependencies from rootProject build.gradle
30+
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
31+
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
32+
implementation "com.google.android.material:material:$materialVersion"
33+
}

find-route/find-route.png

217 KB
Loading

find-route/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.esri.arcgismaps.sample.findroute">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity
15+
android:exported="true"
16+
android:name=".MainActivity"
17+
android:label="@string/app_name">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
26+
</manifest>

0 commit comments

Comments
 (0)