Using Google Fused Location Provider
To get started with Google Fused Location Provider, you need to create a positioning implementation which enables communicating the positions received from the API with the MapsIndoors SDK.
The Position Provider implementation exists at the customer application level, and needs to use the MPPositionProvider interface from the MapsIndoors SDK. The MapsIndoors SDK can then use the positioning results given by the given Position Provider, by setting the Position Provider with MapsIndoors.setPositionProvider(MPPositionProvider).
Fetch Attributes from Solution
You can choose to fetch the Position Provider information (CMS > Solution Details > App Settings > Position Provider) from the CMS as follows:
Map<String, Map<String, Object>> providerConfig = MapsIndoors.getSolution().getPositionProviderConfig();The outer keyset (Map<String, Map<String, Object>>) contains the name of the positioning provider, for example, indooratlas3 for IndoorAtlas, or ciscodna when using Cisco DNA Spaces.
The inner keyset (Map<String, Object>) consist of various attribute fields for a given positioning provider, such as keys, floor mapping etc. These attribute fields will vary across different positioning providers, so refer to their own documentation for details.
Implementing Google Fused Location Provider API
This Guide requires you to already have an activity that shows a MapsIndoors Map and to have the Google Play Services Location library dependency added to your project.
dependencies {
implementation 'com.google.android.gms:play-services-location:18.0.0'
}We will start implementing the Fused Location position provider. Create a class called GPSPositionProvider that implements the MPPositionProvider interface from the MapsIndoors SDK, and create a constructor that takes a Context as parameter and create an instance of the FusedLocationProviderClient.
class GPSPositionProvider(context: Context): MPPositionProvider {
private var fusedLocationClient: FusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context)
private var mLatestPosition: MPPositionResultInterface? = null
}We will start by implementing logic to each of the implemented methods from the MPPositionProvider interface.
We will then start implementing the code to get Google Fused Location positioning up and running.
We start by implementing the startPositioning and stopPositioning methods:
Implement the LocationCallBack to the provider to receive and handle the location updates.
Our implemented positioning provider will be handled in an activity or fragment.
Lastly, we need to tell MapControl that we want to show the position on the map.
A full example implementation of the Google Fused Location position provider can be found here: PositionProviders
Last updated
Was this helpful?