Skip to main content

PositioningSDK - Getting started

Installation

Before starting to develop your application with the WemapSDKs, you'll need to configure your credentials and add the SDK as a dependency.

Add the dependency

Add the WemapSDKs to your app

info

The code examples below show how to configure the WemapPositioningSDK to work with the WemapMapSDK, but it can be used independently of the WemapMapSDK.

  • In your module level Gradle file (usually project/module/build.gradle.kts or project/module/build.gradle), add the dependency for the WemapSDK library for Android.

    dependencies {
    // Add the dependency for the WemapMapSDK library
    implementation "com.getwemap.sdk:map:<version>"

    // Add the dependency for the WemapPositioningSDK library
    implementation "com.getwemap.sdk.positioning:fused-gms:<version>" // Google's Fused Location Source
    implementation "com.getwemap.sdk.positioning:polestar:<version>" // Polestar Location Source
    implementation "com.getwemap.sdk.positioning:wemap-vps-arcore:<version>" // Wemap VPS ARCore Location Source
    }
  • Make sure that your project's minSdkVersion is at API 21 or higher.

    android {
    ...
    defaultConfig {
    minSdkVersion 21
    }
    }
  • Because you've edited your Gradle files, Android Studio will ask you whether you want to sync the Gradle files. You can sync now.

Location Sources

Wemap provides a set of different location sources to manage the user's location on the map. By default, WemapMapSDK uses Android GPS and Network Providers to obtain raw location updates.

To set a specific location source, you need to add a specific WemapPositioningSDK library to your project dependencies and assign it to the map.

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
mapView.getMapViewAsync { _, _, _ ->
... // check permissions
setupLocationSource()
}
}
info

If you want the camera to follow the user's direction, you can do this by changing renderMode and cameraMode of locationManager as shown below

mapView.locationManager.apply {
cameraMode = CameraMode.TRACKING_COMPASS
renderMode = RenderMode.COMPASS
}

Google's Fused location source

fun setupLocationSource() {
mapView.locationManager.apply {
source = GmsFusedLocationSource(applicationContext)
isEnabled = true
}
}

Polestar location source

fun setupLocationSource() {
mapView.locationManager.apply {
source = PolestarLocationSource(applicationContext, "emulator") // change 'emulator' to your polestar API key here
isEnabled = true
}
}

Wemap VPS ARCore location source

To make VPS service work, you need to know VPS service endpoint. For additional information contact Wemap team.

fun setupLocationSource() {
val vpsLocationSource = WemapVPSARCoreLocationSource(applicationContext, "https://your-wemap-vps-endpoint")
vpsLocationSource.vpsListeners.add(vpsListener)

mapView.locationManager.apply {
source = vpsLocationSource
isEnabled = true
}
}

You will also need to react to changes in the state of WemapVPSARCoreLocationSource due to the need to allow the user to scan their environment.

private val vpsListener by lazy {
object : WemapVPSARCoreLocationSourceListener {
override fun onScanStatusChanged(status: WemapVPSARCoreLocationSource.ScanStatus) {
...
}

override fun onStateChanged(state: WemapVPSARCoreLocationSource.State) {
when(state) {
State.SCAN_REQUIRED, State.LIMITED_CORRECTION -> {
// ask user to scan his environment and show camera
}
}
}

override fun onError(error: WemapVPSARCoreLocationSourceError) {
...
}
}
}

Examples

You can find additional examples for the WemapSDKs on GitHub. Clone the repository and run the example application following the instructions in the README.