Repository navigation
Migrating from 1.x
Version 2.0 changes most of the public API. Each 1.x class and method is listed below with its replacement.
1.x was a single artifact. 2.0 has two modules. The quickest upgrade is to the Sceneform module, which keeps LocationScene and LocationMarker. If you'd rather move off Sceneform at the same time, which you'll need to do to publish updates on Google Play, use the core module and follow Getting started. The rest of this page covers the Sceneform module:
// Before
implementation("com.github.appoly:ARCore-Location:1.2")
// After
implementation("com.github.appoly.ARCore-Location:arcore-location-sceneform:2.0.0")2.0 also needs:
- AndroidX. The library no longer uses the old support library.
- Java 17 and minSdk 24.
- The community Sceneform fork,
com.gorisse.thomas.sceneform:core:1.23.0(anduxif you useArFragment), in place ofcom.google.ar.sceneform:core. The fork can't load.sfbmodels, so convert them to glTF or GLB.
This is the change most likely to catch you out. 1.x took longitude first:
// Before: longitude, latitude
new LocationMarker(-0.119677, 51.478494, node);
// After: latitude, longitude
new LocationMarker(GeoCoordinate.of(51.478494, -0.119677), node);GeoCoordinate.of throws if the latitude is outside -90 to 90, which catches most swapped arguments.
| 1.x | 2.0 |
|---|---|
new LocationScene(activity, arSceneView) |
new LocationScene(arSceneView) |
locationScene.processFrame(frame) in your update listener |
Remove it. The scene registers its own update listener. |
resume() and pause() from your activity |
getLifecycle().addObserver(locationScene), or keep calling resume() and pause(), and call destroy() when done. |
mLocationMarkers.add(marker) |
addMarker(marker) |
clearMarkers() |
clearMarkers() |
setDistanceLimit(int) |
setMaxRenderDistanceMetres(float) |
setOffsetOverlapping(true) |
setOverlapMode(OverlapMode.STACK) |
setRemoveOverlapping(true) |
setOverlapMode(OverlapMode.HIDE) |
setAnchorRefreshInterval, setMinimalRefreshing, setRefreshAnchorsAsLocationChanges, refreshAnchors()
|
Remove them. Markers are re-anchored when their ideal position moves by more than setRepositionToleranceMetres (default 0.3 m). |
setBearingAdjustment(int) |
Remove it. Magnetic declination is now corrected automatically. To supply your own heading, pass a custom HeadingSource to GeoTracker. |
setDebugEnabled(true) |
Listen to getTracker() status changes instead of relying on toasts. |
setLocationChangedEvent(DeviceLocationChanged) |
getTracker().addListener(...) and override onLocationAccepted. |
deviceLocation.currentBestLocation |
getTracker().getCameraLocation(cameraPose) for the filtered estimate, or getTracker().getLastAcceptedLocation() for the last reading. |
deviceOrientation |
Removed. |
| 1.x | 2.0 |
|---|---|
new LocationMarker(lng, lat, node) |
new LocationMarker(GeoCoordinate.of(lat, lng), node) |
longitude, latitude fields |
getCoordinate() and setCoordinate(GeoCoordinate)
|
anchorNode field |
getAnchorNode(), which is null while the marker has no anchor |
setRenderEvent(LocationNodeRender) |
setOnRenderListener(marker -> ...) |
node.getDistance() inside the render event |
marker.getDistanceMetres() |
setOnlyRenderWhenWithin(int) |
setOnlyRenderWhenWithinMetres(double) |
setHeight(float) |
setHeight(float). See the note below. |
setScalingMode(LocationMarker.ScalingMode.X) |
setScalingMode(ScalingMode.X). The enum is now a top-level class. |
setScaleModifier, setGradualScalingMinScale, setGradualScalingMaxScale
|
Unchanged, and the setters now return the marker so you can chain them. |
Height is still measured from the camera when a marker has no altitude. In 1.x a later step overwrote it with an absolute world height, so markers that relied on that bug may now sit higher or lower. If the marker's GeoCoordinate has an altitude and the tracker knows the scene's altitude (usually only with the Geospatial API), height is measured from that altitude instead.
GRADUAL_FIXED_SIZE now scales between the maximum and minimum gradual scale across the render distance. Before 1.3 it effectively always used the minimum.
| 1.x | 2.0 |
|---|---|
ARLocationPermissionHelper |
ArLocationPermissions. Pass REQUIRED_PERMISSIONS to an Activity Result launcher. Fine and coarse location are now requested together. |
LocationUtils.distance(lat1, lat2, lon1, lon2, el1, el2) |
GeoMath.distanceMetres(from, to) |
LocationUtils.bearing(lat1, lon1, lat2, lon2) |
GeoMath.bearingDegrees(from, to) |
DeviceLocation, DeviceOrientation, KalmanLatLong
|
Removed. GeoTracker handles location and heading. To use your own providers, implement LocationSource or HeadingSource. |
LocationNode, LocationNodeRender
|
Removed. Use LocationMarker.getAnchorNode() and setOnRenderListener. |
// 1.x
arSceneView.getScene().setOnUpdateListener(frameTime -> {
if (locationScene == null) {
locationScene = new LocationScene(this, arSceneView);
locationScene.mLocationMarkers.add(new LocationMarker(-0.119677, 51.478494, getAndy()));
}
Frame frame = arSceneView.getArFrame();
if (frame != null && frame.getCamera().getTrackingState() == TrackingState.TRACKING) {
locationScene.processFrame(frame);
}
});
// 2.0
locationScene = new LocationScene(arSceneView);
getLifecycle().addObserver(locationScene);
locationScene.addMarker(new LocationMarker(GeoCoordinate.of(51.478494, -0.119677), getAndy()));