Skip to content

Commit 9221a30

Browse files
authored
Merge pull request #34 from Esri/sample/Display-device-location-with-NMEA-data-sources
Display device location with nmea data sources
2 parents fd6fd7b + c528cf3 commit 9221a30

29 files changed

+797
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Display device location with NMEA data sources
2+
3+
This sample demonstrates how to parse NMEA sentences and use the results to show device location on the map.
4+
5+
![Image of display device location with nmea data sources](display-device-location-with-nmea-data-sources.png)
6+
7+
## Use case
8+
9+
NMEA sentences can be retrieved from GPS receivers and parsed into a series of coordinates with additional information. Devices without a built-in GPS receiver can retrieve NMEA sentences by using a separate GPS dongle, commonly connected via bluetooth or through a serial port.
10+
11+
The NMEA location data source allows for detailed interrogation of the information coming from the GPS receiver. For example, allowing you to report the number of satellites in view.
12+
13+
## How to use the sample
14+
15+
Click floating button "Play" to parse the provided NMEA sentences into a location data source, and display the location position and related satellite information. Click "Stop" to stop displaying the location information. The sample will automatically re-center the location data source as it moves across the map.
16+
17+
## How it works
18+
19+
1. Load NMEA sentences from a local file.
20+
2. Parse the NMEA sentence strings, and push data into `NmeaLocationDataSource`.
21+
3. Set the `NmeaLocationDataSource` to the `LocationDisplay`'s data source.
22+
4. Start the location display to begin receiving location and satellite updates.
23+
24+
## Relevant API
25+
26+
* LocationDisplay
27+
* NmeaLocationDataSource
28+
* NmeaSatelliteInfo
29+
30+
## About the data
31+
32+
This sample reads lines from a local file to simulate the feed of data into the `NmeaLocationDataSource`. This simulated data source provides NMEA data periodically, and allows the sample to be used on devices without a GPS dongle that produces NMEA data.
33+
34+
The route taken in this sample features a [one minute driving trip around Redlands, CA](https://arcgis.com/home/item.html?id=d5bad9f4fee9483791e405880fb466da).
35+
36+
## Tags
37+
38+
GPS, history, navigation, NMEA, real-time, trace
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"category": "Maps and Scenes",
3+
"description": "This sample demonstrates how to parse NMEA sentences and use the results to show device location on the map.",
4+
"formal_name": "DisplayDeviceLocationWithNmeaDataSources",
5+
"ignore": false,
6+
"images": [
7+
"display-device-location-with-nmea-data-sources.png"
8+
],
9+
"keywords": [
10+
"GPS",
11+
"NMEA",
12+
"history",
13+
"navigation",
14+
"real-time",
15+
"trace",
16+
"LocationDisplay",
17+
"NmeaLocationDataSource",
18+
"NmeaSatelliteInfo"
19+
],
20+
"language": "kotlin",
21+
"redirect_from": "",
22+
"relevant_apis": [
23+
"LocationDisplay",
24+
"NmeaLocationDataSource",
25+
"NmeaSatelliteInfo"
26+
],
27+
"snippets": [
28+
"src/main/java/com/esri/arcgismaps/sample/displaydevicelocationwithnmeadatasources/MainActivity.kt",
29+
"src/main/java/com/esri/arcgismaps/sample/displaydevicelocationwithnmeadatasources/DownloadActivity.kt"
30+
],
31+
"title": "Display device location with NMEA data sources"
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.displaydevicelocationwithnmeadatasources"
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 "com.google.android.material:material:$materialVersion"
32+
implementation 'androidx.appcompat:appcompat:1.5.1'
33+
implementation project(path: ':samples-lib')
34+
}
83 KB
Loading
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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.displaydevicelocationwithnmeadatasources">
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:name=".DownloadActivity"
16+
android:exported="true">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
22+
<meta-data
23+
android:name="android.app.lib_name"
24+
android:value="" />
25+
</activity>
26+
<activity
27+
android:name=".MainActivity"
28+
android:exported="true"
29+
android:label="@string/app_name">
30+
<intent-filter>
31+
<action android:name="android.intent.action.MAIN" />
32+
</intent-filter>
33+
</activity>
34+
</application>
35+
36+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.esri.arcgismaps.sample.displaydevicelocationwithnmeadatasources
2+
3+
import android.content.Intent
4+
import androidx.appcompat.app.AppCompatActivity
5+
import android.os.Bundle
6+
import android.view.View
7+
import com.esri.arcgismaps.sample.sampleslib.DownloaderActivity
8+
9+
class DownloadActivity : DownloaderActivity() {
10+
override fun onCreate(savedInstanceState: Bundle?) {
11+
super.onCreate(savedInstanceState)
12+
downloadAndStartSample(
13+
Intent(this, MainActivity::class.java),
14+
// get the app name of the sample
15+
getString(R.string.app_name),
16+
listOf(
17+
// ArcGIS Portal item containing the Redlands.nmea
18+
// which features a vehicle driving around southern Redlands, CA.
19+
"https://www.arcgis.com/home/item.html?id=d5bad9f4fee9483791e405880fb466da"
20+
)
21+
22+
)
23+
}
24+
}

0 commit comments

Comments
 (0)