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).
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.
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.
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.
classMyFragment: Fragment(), OnMapReadyCallback {privatevar mPositionProvider: GPSPositionProvider? =nulloverridefunonCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,): View {... mPositionProvider =GPSPositionProvider(requireActivity()) MapsIndoors.load(requireActivity().applicationContext, "myapikey") {// Attach the position provider to the SDK MapsIndoors.setPositionProvider(mPositionProvider) }//Have a buttton or other logic to start positioning: binding.startPositioningButton.setOnClickListener {//Remember to handle permissions specific to the Position provider you are using mPositionProvider?.startPositioning() }... }}
Lastly, we need to tell MapControl that we want to show the position on the map.
MapControl.create(mapConfig) { mapControl: MapControl?, miError: MIError? -> mMapControl = mapControl// Enable showing the position indicator (aka. the blue dot) mMapControl?.showUserPosition(true)}
A full example implementation of the Google Fused Location position provider can be found here: PositionProviders