Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

How to set map boundaries in android ? #3321

Closed
Mizuki123 opened this issue Dec 16, 2015 · 5 comments
Closed

How to set map boundaries in android ? #3321

Mizuki123 opened this issue Dec 16, 2015 · 5 comments
Labels
Android Mapbox Maps SDK for Android support

Comments

@Mizuki123
Copy link

Hi everyone,

I'm working on an android application that display a portion of world map (including part of United Kingdom, part of France and part of Span) and I want to restrict the moving on the map to only this portion of map.

In my android code, I used setVisibleCoordinateBounds to define Porto as south-west bounds and Utrecht to north-east bounds but I can still moving out of this bounds.

In addition, I set those bounds in my stylesheet using the "bounds" property of the source node but that does not working. Seems the default boundaries are set to my map.

So Is it possible to set the bound of my mapView and how to do that ?

I notice there is a way to do that in javascrip using the maxBounds : https://www.mapbox.com/mapbox.js/example/v1.0.0/maxbounds/

Is there a equivalent of this in Android ?

@tobrun tobrun added Android Mapbox Maps SDK for Android feature request support labels Jan 27, 2016
@tobrun
Copy link
Member

tobrun commented Jan 27, 2016

@Mizuki123
Sorry for getting back to you this late.
Currently this is not supported yet.
There is a feature request for this in issue #3602.

@tobrun tobrun closed this as completed Jan 27, 2016
@bodhidipta
Copy link

Hi, can you please give us an alternative for it?

@tobrun
Copy link
Member

tobrun commented Oct 20, 2016

Listen to OnCameraChangeListener events. Detect if the camera position is contained within the LatLngBounds and move camera if not.

@bodhidipta
Copy link

Thank you .

On Thu 20 Oct, 2016 7:27 pm Tobrun, notifications@github.com wrote:

Listen to OnCameraChangeListener events. Detect if the camera position is
contained within this LatLngBounds and move camera if not.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#3321 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ASyg7oqHX4XX0cjDVICv-uQY8fOQ_jIbks5q13NQgaJpZM4G2iwy
.

@sddamico
Copy link

Having implemented something to do this recently, the callbacks from onCameraChange do not align with the drawing frames and this can lead to "bouncing" on the edge of the bounded area. I recommend using a Runnable that performs the check on each choreographer frame by using postOnAnimation on the MapView itself

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android support
Projects
None yet
Development

No branches or pull requests

4 participants