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 Podfile, add the WemapSDK pods that you want to use in your app.

    use_frameworks!

    target 'TargetNameOfYourApp' do
    # Add the dependency for the WemapPositioningSDK library
    pod 'WemapPositioningSDKPolestar', '<version>' # Polestar Location Source
    pod 'WemapPositioningSDK/VPSARKit', '<version>' # Wemap VPS ARKit Location Source

    # Optionally, add the dependency for the WemapMapSDK library
    pod 'WemapMapSDK', '<version>'
    end
  • Make sure that your project target this platform version or later:

    platform :ios, '12.0'
  • Install the pods, then open your .xcworkspace file to see the project in Xcode:

    AWS_ACCESS_KEY_ID=*** \
    AWS_SECRET_ACCESS_KEY=*** \
    AWS_REGION=*** \
    [bundle exec] pod install --repo-update
    open your-project.xcworkspace

Location Sources

Wemap provides a set of different location sources to manage the user's location on the map. By default, WemapMapSDK uses Apple's LocationProvider 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 func viewDidLoad() {
super.viewDidLoad()

setupLocationSource()
}
info

If you want the camera to follow the user's direction, you can do this by changing userTrackingMode of the map as shown below

map.userTrackingMode = .followWithHeading

Polestar location source

func setupLocationSource() {
let source = PolestarLocationSource(apiKey: "emulator")
map.userLocationManager.locationSource = source
}

Wemap VPS ARKit location source

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

func setupLocationSource() {
let source = VPSARKitLocationSource(serviceURL: URL(string: "https://your-wemap-vps-endpoint")!)
source.vpsDelegate = self
map.userLocationManager.locationSource = source
}

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

extension ViewController: VPSARKitLocationSourceDelegate {

func locationSource(_ locationSource: VPSARKitLocationSource, didChangeState state: VPSARKitLocationSource.State) {
if state == .scanRequired {
// ask user to scan his environment and show camera
}
}

func locationSource(_ locationSource: VPSARKitLocationSource, didChangeScanStatus status: VPSARKitLocationSource.ScanStatus) {
...
}

func locationSource(_ locationSource: VPSARKitLocationSource, didFailWithError error: VPSARKitLocationSourceError) {
...
}
}

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.