tangrams / tangram-es

2D and 3D map renderer using OpenGL ES
MIT License
827 stars 240 forks source link

Enable restricting viewable map regions #2034

Open matteblair opened 5 years ago

matteblair commented 5 years ago

For some applications it is useful to allow users some degree of movement within the map, but to restrict that movement within some bounds. This could be a latitude/longitude range, a zoom range, or something else entirely. This is the need described in #1962 and #1431. This issue will track this need as a feature enhancement.

matteblair commented 5 years ago

For comparison, the Mapbox iOS SDK provides a very general delegate function to solve this:

- (BOOL)mapView:(nonnull MGLMapView *)mapView
    shouldChangeFromCamera:(nonnull MGLMapCamera *)oldCamera
                  toCamera:(nonnull MGLMapCamera *)newCamera;

https://docs.mapbox.com/ios/api/maps/4.8.0/Protocols/MGLMapViewDelegate.html#/c:objc(pl)MGLMapViewDelegate(im)mapView:shouldChangeFromCamera:toCamera:

Whereas the Google Maps Android SDK has a more explicit function:

public void setLatLngBoundsForCameraTarget (LatLngBounds bounds)

https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.html#setLatLngBoundsForCameraTarget(com.google.android.gms.maps.model.LatLngBounds)

liodali commented 3 years ago

in osmdroid their is feature that limit scrollable area how i can implement that using tangram sdk or it's not possible for now ?

matteblair commented 3 years ago

There still isn't built-in support for this in Tangram ES. The best you can do for now is intercept panning events with a PanResponder and restrict movement from there.