android – How to limit the display area of ​​google maps?


It is necessary to make sure that a certain area (from such and such to such and such latitude, from such and such to such and such longitude) is shown on Google maps for android, and the rest of the world map cannot be viewed.

Is there such functionality out of the box or does it need to be done somehow via OnCameraChangeListener for example?

If someone has come across this, what is the easiest way to implement it?


The easiest way is to track the change in the position of the camera through the Listener, and if the coordinates get out of the limits of the available ones, then assign them the nearest allowed ones, i.e. move the camera there, so the user will be able to crawl out a little beyond the border of the selected area, but will immediately be transferred back to the area.

Scroll to Top