Installation

Before you start developing your application with WemapSDKs, you need to configure your credentials and add the SDK as a dependency.

The code examples below show how to configure the WemapPositioningSDK to work with custom map, but it can be used with WemapMapSDK. Instructions are here

Adding the Dependency

To add WemapSDKs to your app:

  1. Add Dependencies in the Podfile

    Add the required WemapSDK pods to your app:

    use_frameworks!
    
    target 'TargetNameOfYourApp' do
        # Add the dependency for the WemapPositioningSDK library
        pod 'WemapPositioningSDK/VPSARKit', '<version>' # Wemap VPS ARKit Location Source
    end
    
  2. Ensure Minimum iOS Version

    Your project must target iOS 12.0 or later:

    platform :ios, '12.0'
    
  3. Install Dependencies and Open the Project

    Run the following command to install the pods:

    AWS_ACCESS_KEY_ID=*** \
    AWS_SECRET_ACCESS_KEY=*** \
    AWS_REGION=*** \
    bundle exec pod install --repo-update
    

    Then, open your project in Xcode:

    open your-project.xcworkspace
    

Location Sources

Wemap provides various location sources to track the user’s location on the map.

To set a specific location source, you need to:

  • Add the relevant WemapPositioningSDK library to your project dependencies.

  • Assign the location source to the map.

Wemap VPS ARKit Location Source

To use the VPS Location Source, you must have a mapID and token or a VPS serviceURL. For more details, please contact Wemap team.

Fetching the VPS Service URL

ServiceFactory
    .getMapService()
    .map(byID: 19158, token: "GUHTU6TYAWWQHUSR5Z5JZNMXX")
    .observe(on: MainScheduler.asyncInstance)
    .subscribe(onSuccess: { mapData in
        // mapData contains the VPS service URL
    }, onFailure: {
        debugPrint("Failed to get map data with error - \($0)")
    })
    .disposed(by: disposeBag)

Setting Up the VPS ARKit Location Source

Once you have the serviceURL, create a VPSARKitLocationSource instance:

func setupLocationSource() {
    vpsLocationSource = VPSARKitLocationSource(serviceURL: mapData?.extras?.vpsEndpoint ?? "https://your-wemap-vps-endpoint")
    vpsLocationSource.delegate = self
    vpsLocationSource.vpsDelegate = self

    vpsLocationSource.start()
}

Handling Location Source State Changes

You must handle state changes in VPSARKitLocationSourceDelegate, as users may need to scan their environment.

extension VPSViewController: VPSARKitLocationSourceDelegate {

    func locationSource(_ locationSource: VPSARKitLocationSource, didChangeState state: VPSARKitLocationSource.State) {
        // Handle state changes
    }

    func locationSource(_ locationSource: VPSARKitLocationSource, didChangeScanStatus status: VPSARKitLocationSource.ScanStatus) {
        // Handle scan status changes
    }

    func locationSource(_ locationSource: VPSARKitLocationSource, didFailWithError error: VPSARKitLocationSourceError) {
        // Handle location source errors
    }
}

Retrieving User’s Coordinate and Attitude

To get the user’s coordinate and attitude, implement LocationSourceDelegate:

extension VPSViewController: LocationSourceDelegate {

    func locationSource(_ locationSource: any LocationSource, didUpdateCoordinate coordinate: Coordinate) {
        // Pass the updated coordinate to your map implementation
    }

    func locationSource(_ locationSource: any LocationSource, didUpdateAttitude attitude: Attitude) {
        // Pass the updated attitude to your map implementation
    }

    func locationSource(_ locationSource: any LocationSource, didFailWithError error: any Error) {
        // Handle errors
    }
}

Scanning the Environment

To start tracking the user’s location, you need to allow the user to scan their environment:

func startScan() {
    vpsLocationSource.startScan()
}

Once the system successfully recognizes the user’s location, it will report the accuratePositioning state to VPSARKitLocationSourceDelegate. Shortly after, you will start receiving updated Coordinate and Attitude values in LocationSourceDelegate.

Examples

For additional examples and sample implementations of WemapSDKs, visit the official GitHub repository.

Clone the repository and follow the README instructions to run the sample application.