GeoARSDK - Getting started
The WemapGeoARSDK is a library for enabling AR navigation within mobile applications.
Requirements
In addition to common requirement WemapGeoARSDK supports Android SDK 24 and newer.
Installation
Check common installation.
Permissions
WemapGeoARSDK requires camera permission to be able to show camera background for AR. Declare android.permission.CAMERA in your app Manifest as follows:
<uses-permission android:name="android.permission.CAMERA" />
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.
private val cameraPermissionHandler =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
if (!granted) {
// User denied camera access. show a message explaining how to enable it
return
}
// User granted camera access. Continue with GeoARView
}
fun requestCameraPermission() {
// show a model explaining that camera access is crucial for AR
// then check if it's arealy granted and request if not yet
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
// User already granted camera access, Continue with GeoARView
} else {
requestCameraPermission.launch(Manifest.permission.CAMERA)
}
}
Add a GeoARView
At first add GeoARView to your layout:
<com.getwemap.sdk.geoar.GeoARView
android:id="@+id/geoARView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Once you have the MapData, assign MapData to the GeoARView as follows:
geoARView.mapData = mapData
Wait GeoARView to load
You must wait until GeoARView finishes loading view getARViewAsync, because only when this method is called, it's safe to access GeoARView properties.
geoARView.getARViewAsync { geoARView, 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:
fun setupLocationSource(mapData: MapData) {
vpsLocationSource = WemapVPSARCoreLocationSource(requireContext(), mapData) // it can be any LocationSource from WemapPositioningSDK
vpsLocationSource.vpsListeners.add(vpsListener)
geoARView.locationManager.locationSource = source
}
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.