Skip to main content

GeoARSDK - Getting started

The WemapGeoARSDK is a library for enabling AR navigation within mobile applications.

Requirements

Check common requirement.

Installation

Check common installation.

Permissions

WemapGeoARSDK requires camera permission to be able to show camera background for AR. Declare NSCameraUsageDescription in your app Info.plist as follows:

<key>NSCameraUsageDescription</key>
<string>Camera is used to show navigation in AR, understand your surroundings and provide accurate indoor navigation</string>

Please request camera permission before creating and presenting GeoARView, because without access to the camera - system can't work. If you don't do it, system will request permission on first access to camera. But if user denied access - black screen will be shown instead of camera background.

func requestCameraPermission() {
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized:
// User already granted camera access. Continue with GeoARView
case .notDetermined:
// show a model explaining that camera access is crucial for AR to work
// then request for camera permission
AVCaptureDevice.requestAccess(for: .video) { granted in
guard granted else {
// User denied camera access. show a message explaining how to enable it
return
}
// User granted camera access. Continue with GeoARView
}
default:
// denied or restricted
break
}
}

Add a GeoARView

Once you have the MapData, create a GeoARView instance, assign viewDelegate and MapData to the GeoARView and present the view as follows:

func showGeoARView(mapData: MapData) {
geoARView = GeoARView(frame: view.bounds)
geoARView.viewDelegate = self
geoARView.mapData = mapData
view.addSubview(geoARView)
}

Handling GeoARViewDelegate

You must handle at least geoARViewLoaded method in GeoARViewDelegate, because only when this method is called, it's safe to access GeoARView properties.

extension ViewController: GeoARViewDelegate {

func geoARViewLoaded(_ geoARView: GeoARView, mapData: MapData) {
// now it's safe to access GeoARView properties
}
}

User Location

Wemap provides various location sources to track the user's location. For more info check positioning docs

There is no default LocationSource embedded into WemapGeoARSDK, so you have to choose one. You can easily do it by taking any WemapPositioningSDK, creating LocationSource and connecting it to the GeoARView as shown below:

func setupLocationSource(mapData: MapData) {
let locationSource = VPSARKitLocationSource(mapData: mapData) // it can be any LocationSource from WemapPositioningSDK
geoARView.locationManager.locationSource = locationSource
}

The full example is available in our GitHub repository.

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.