The SDK allows you to listen to certain events on the map some of the events are listed below :
- addOnCameraMoveStartedListener & onCameraMoveStarted(int reason) : Listens or looks for any camera movement or animation added by the developer.
Java
mapplsMap.addOnCameraMoveStartedListener(new MapplsMap.OnCameraMoveStartedListener() {
private final String REASONS = {
“REASON_API_GESTURE”,
“REASON_DEVELOPER_ANIMATION”,
“REASON_API_ANIMATION”};
@Override
public void onCameraMoveStarted(int reason) {
String string = String.format(Locale.US, “OnCameraMoveStarted: %s”, REASONS[reason - 1]);
Toast.makeText(MainActivity.this, string, Toast.LENGTH_LONG).show();
}
});
Kotlin
mapplsMap.addOnCameraMoveStartedListener(object : MapplsMap.OnCameraMoveStartedListener {
private val REASONS: Array = arrayOf(
“REASON_API_GESTURE”,
“REASON_DEVELOPER_ANIMATION”,
“REASON_API_ANIMATION”
)
override fun onCameraMoveStarted(i: Int) {
var string: String = String.format(“OnCameraMoveStarted: %s”, REASONS[i - 1])
Toast.makeText(this@MainActivity, string, Toast.LENGTH_SHORT).show()
}
})
- addOnCameraMoveCancelListener : It sets a callback that is invoked when camera movement was cancelled.
Java
mapplsMap.addOnCameraMoveCancelListener(new MapplsMap.OnCameraMoveCanceledListener() {
@Override
public void onCameraMoveCanceled() {
Toast.makeText(MainActivity.this, “onCameraMoveCanceled”, Toast.LENGTH_LONG).show();
}
});
Kotlin
mapplsMap.addOnCameraMoveCancelListener(object : MapplsMap.OnCameraMoveCanceledListener {
override fun onCameraMoveCanceled() {
Toast.makeText(this@MainActivity, “onCameraMoveCanceled”, Toast.LENGTH_SHORT).show()
}
})
For more Map Events : https://github.com/mappls-api/mappls-android-sdk/blob/main/docs/v1.0.6/Getting-Started.md#map-events