Search code examples
androidgoogle-mapscity

How to restrict android google map to a city?


How can i restrict android google map to a city?
I am currently following code for show google map:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

I want to show just a city. Any way?


Solution

  • private static final LatLngBounds DUBAI_BOUNDS = new LatLngBounds(new LatLng(24.5908366068, 54.84375),
                new LatLng(25.3303729706, 55.6835174561));
    
    
    map.setLatLngBoundsForCameraTarget(DUBAI_BOUNDS);