Created
October 16, 2021 20:29
-
-
Save kuwapa/6724d2352beee142d469b51e111f05fb to your computer and use it in GitHub Desktop.
restricting map to bounds. Gist #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0), | |
object : MapboxMap.CancelableCallback { | |
override fun onCancel() {} | |
override fun onFinish() { | |
map.setMinZoomPreference(map.cameraPosition.zoom) | |
map.limitViewToBounds(bounds) | |
map.addOnScaleListener(object : MapboxMap.OnScaleListener { | |
override fun onScaleBegin(detector: StandardScaleGestureDetector) {} | |
override fun onScale(detector: StandardScaleGestureDetector) { | |
map.limitViewToBounds(bounds) | |
} | |
override fun onScaleEnd(detector: StandardScaleGestureDetector) {} | |
}) | |
map.addOnCameraIdleListener { map.limitViewToBounds(bounds) } | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment