Reputation: 1037
In my app I'm using Google maps. I refresh data from API every time onCameraIdle()
is being called. I know it's not good solution. My question is - can I detect if user swiped more than half of visible region and only then load data ? I don't know if my question is clear, if not , let me know, I will try to write it more precisely. Thank you!
Upvotes: 0
Views: 66
Reputation: 882
You can use the projection visible region and the camera target to achieve what you want:
cameraTarget = map.cameraPosition.target
when (viewPort?.contains(cameraTarget)) {
true -> {
// Did not scroll more than half (camera center still inside initial bounds)
}
false -> {
// Scrolled more than half (camera center outside initial bounds)
}
}
viewPort = map.projection.visibleRegion.latLngBounds
Upvotes: 2