goTo

fun goTo(entity: MPEntity?, behavior: MPCameraBehavior = MPCameraBehavior.DEFAULT, onCameraEvent: MPCameraEventListener? = null)

Focus the map on the given MPEntity, and optionally report back when the camera stops.

Examples of classes of type MPEntity are: MPVenue, MPBuilding, MPFloor, MPLocation.

Leaving out behavior uses MPCameraBehavior.DEFAULT; leaving out onCameraEvent moves the camera without reporting back.

If onCameraEvent is non-null it is invoked exactly once, asynchronously on the main thread — never before goTo returns — with either MPCameraEvent.FINISHED or MPCameraEvent.CANCELLED, and never with any other MPCameraEvent value. FINISHED means the camera reached the requested pose. CANCELLED means anything else: pre-empted by a later camera move or a gesture, no usable geometry, or the map went away. Completion means the camera stopped, not MapsIndoors finished drawing. Use addOnCameraEventListener for the continuous camera-state stream.

A move still in flight when onDestroy runs is reported as CANCELLED, and because delivery hops the main looper that report lands on a later frame — after onDestroy(), and typically after Activity.onDestroy(), has returned. A listener that touches views or fragments should check that its host is still alive.

mapControl.goTo(venue)                    // default behaviour, no callback
mapControl.goTo(venue, paddedSlowFly) // custom behaviour, no callback
mapControl.goTo(location) { event -> // default behaviour, awaiting the camera
if (event == MPCameraEvent.FINISHED) showDetailPanel(location)
}

Parameters

entity

The MPEntity you want the camera to focus on

behavior

An MPCameraBehavior that dictates how the camera moves

onCameraEvent

Notified once the camera has stopped, or null to not be notified


fun goTo(entity: MPEntity?, maxZoom: Double?)

Deprecated

Use goTo(entity, MPCameraBehavior) instead. Note that goTo(entity, null) is now ambiguous from Java: write goTo(entity) or goTo(entity, (Double) null).

Replace with

goTo(entity, MPCameraBehavior.Builder().setMaxZoom(maxZoom).build())

Focus the map on the given MPEntity, capping how far the camera zooms in.

Examples of classes of type MPEntity are: MPVenue, MPBuilding, MPFloor, MPLocation.

From Java, goTo(entity, null) is ambiguous: two overloads take a reference type in second position. Write goTo(entity) for the default behaviour, or goTo(entity, (Double) null) to reach this one. Kotlin resolves it without help, since this is the only overload whose second parameter is nullable.

maxZoom must be finite and greater than 1, and is validated by MPCameraBehavior.Builder.setMaxZoom: in developer mode an invalid value throws IllegalArgumentException from this call, and otherwise it is ignored and logged, leaving the camera uncapped. In particular 0.0 is not a way to hold the camera where it is — build a behaviour with MPCameraBehavior.Builder.setZoomToFit false for that.

Parameters

entity

The MPEntity you want the camera to focus on

maxZoom

An upper bound on how far the camera zooms in, or null for none. See MPCameraBehavior.maxZoom for how the bound applies per entity type