Skip to content

Instantly share code, notes, and snippets.

@mizutori
Created January 6, 2019 09:24
Show Gist options
  • Save mizutori/a593e5c5628651935316e2ee3d995f02 to your computer and use it in GitHub Desktop.
Save mizutori/a593e5c5628651935316e2ee3d995f02 to your computer and use it in GitHub Desktop.
private fun zoomMapTo(location: Location) {
val latLng = LatLng(location.latitude, location.longitude)
if (this.didInitialZoom == false) {
try {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17.5f))
this.didInitialZoom = true
return
} catch (e: Exception) {
e.printStackTrace()
}
//Toast.makeText(this.getActivity(), "Inital zoom in process", Toast.LENGTH_LONG).show();
}
if (zoomable) {
try {
zoomable = false
map.animateCamera(CameraUpdateFactory.newLatLng(latLng),
object : GoogleMap.CancelableCallback {
override fun onFinish() {
zoomable = true
}
override fun onCancel() {
zoomable = true
}
})
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment