Map shows correctly, then I check that the map is fully loaded before I do the moveCamera on it. The map then shows the correct area as defined by the bounds. But after the move, the setOnCameraIdleListener is never called as is expected. Here is the bit of code of question
map.setOnMapLoadedCallback(GoogleMap.OnMapLoadedCallback {
Log.e(tag, "setOnMapLoadedCallback")
//set camera bounds
map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100))
})
map.setOnCameraIdleListener {
//create snapshot
Log.e(tag, "setOnCameraIdleListener")
}
I am using lite mode for the map and according to the documentation it looks like it should be supported but I couldn't find anything definite.
What may I be missing?
UPDATE:
Here is how I worked around this bug in the SDK.
Created a val defined as the callback.
private val snapshotReadyCallback : GoogleMap.SnapshotReadyCallback = GoogleMap.SnapshotReadyCallback {
SaveSnapshot(it)
}
"it" is a bitmap of the map. You could do the saving directly in the callback but I call a function instead.
Within setOnMapLoadedCallback did the following
gmap?.setOnMapLoadedCallback {
gmap?.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100))
//2 seconds lag to ensure camera has had time to move
//since camera move override doesnt work in setOnMapLoadedCallback
handler.postDelayed({ // Do something after 2s = 2000ms
gmap?.snapshot(snapshotReadyCallback)
}, 2000)
}
Adding the delay to grab the snapshot allowed enough time for the camera to have moved already. It will then call the snapshotReadyCallback which will then call a function that does the actual saving.