Have you made a great app for outdoor use, that would benefit from high accuracy location? Do your users want to improve the location that they capture or report in your app, by using an external receiver? Do you want to report a location in your app that is being fed from a receiver that is remote to you but available over a network? In each of these cases, you will want to add the ability to search for, and connect to, an external GNSS receiver in your app.
We have recently added this ability to a number of our apps – Trek2There, Survey123, QuickCapture – and now we have made that work available to you, as a small collection of custom components, so you can drop them into your own app.
There are a few considerations you need to evaluate before adding GNSS device discovery to your app – what hardware are you intending your app to be used on, what receivers you want to support – jump to the end of this post to explore those.
For now, I want to show you the mechanics of making this work. The code that you can add to your app is available as an AppStudio sample called GNSS Discover. You can download this directly to your computer and copy and paste contents of it to your app.
The following steps will demonstrate how to add GNSS device discovery to the Hello World (Runtime) starter app. I’ve deliberately chosen this lightweight app so you can see the few steps that it takes to add this complex functionality.
import "./GNSSPlugin"
// Manage connections to GNSS providers
GNSSManager {
id: gnssManager
gnssSettingsPages: gnssSettingsPages
}
// GNSS settings UI
GNSSSettingsPages {
id: gnssSettingsPages
gnssManager: gnssManager
}
// GNSS status UI
GNSSStatusPages {
id: gnssStatusPages
gnssManager: gnssManager
gnssSettingsPages: gnssSettingsPages
}
locationDisplay {
positionSource: gnssManager
}
Save your work. If you choose to run your app at this stage (Alt+Shift+R), you will see the map launch and it will have two buttons, a home and location
button.
Click the location button and see that the map will center on your current location. By default, the app is using your devices internal position source. To be able to use an external receiver, you need to be able to select one. We will next add a settings button , so you have somewhere to select a new receiver.
"./GNSSPlugin/images/round_settings_white_24dp.png"
settingsButton
gnssSettingsPages.showLocationSettings()
Run your app. See that there is now an additional button with the settings icon. Click on this button and see the settings page. On this page you can choose to connect to a GNSS receiver that is connected to your device.
import QtGraphicalEffects 1.12
ColorOverlay {
anchors.fill: settingsButtonImage
source: settingsButtonImage
color: "black"
}
Ensure that the name for anchors.fill and source is the same as the name that your gave your settings button image in the previous step.
Instead of cloning and modifying an existing button, there is a settings button component in the GNSS Discover sample that you also could have used. Steps 12-17 show how you add new functionality to your app whilst maintaining the existing presentation of tools.
Also included in the GNSS Discover sample is a status button that indicates when the position source is connected, and when clicked, displays information coming from that position source. In the next step, we will add this button as is.
GNSSStatusButton {
gnssStatusPages: gnssStatusPages
}
Save your work and run your app. The status button is only visible when the location is active, so first click the location button for the status button to appear. See that the status button has different styling to your other buttons. You can choose to style it as you wish. Click on the status button to see information coming from the position source.
You can add the components from the GNSS Discover sample to any other app in a similar way. Just include the GNSSPlugin folder in your app and reference the GNSS Manager, GNSS Settings and GNSS Status pages in your app. You can choose how to launch the settings and status pages to suit your needs. For alternative examples on how to launch those pages, take a look at the code for the GNSS Discover sample itself. This sample shows buttons for the status and settings pages, that appear on the toolbar of the sample app.
An app that needs to communicate with external GNSS hardware needs the high accuracy location and Bluetooth capabilities to be set.
Also, to be able to work on iOS devices, the receiver must be part of the MFi program as well as support the output of NMEA sentences.
Whilst building your app, we recommend you test in AppStudio Player. Player already has many GNSS receivers whitelisted so you can test your app on iOS before whitelisting your own app.
To learn more about using GNSS receivers with your apps see https://doc.arcgis.com/en/appstudio/api-guide/apihighaccuracygps.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.