I am totally new to google\'s maps api for android and I was wondering if it is possible to restrict the area the map is showing to one country only. I mean my target users
You can restrict the user view to specific square -maybe- of the map, to do so, you can use the following:
private GoogleMap mMap;
// Create a LatLngBounds that includes the city of Adelaide in Australia.
private LatLngBounds ADELAIDE = new LatLngBounds(
new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));
// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);
in this case, the user will not be able to zoom in, in the map in areas where the camera is totally out of the range -square- you specified.
for more details, source: https://developers.google.com/maps/documentation/android-api/views#restricting_the_users_panning_to_a_given_area
you can override the map and specific the latitude and longitude and zoom in with suitable for you and disable the gesture of map see this example it is answered before
limit scrolling and zooming Google Maps Android API v2
out of the box this is not possible. However what you could theoretically do it find the max bounding box that shows the country in question then everytime the camera moves check to make sure the bounding box is inside the max one. If it is not set it to the max. that would restrict them to a certain spot
I am pretty sure you cannot only display your chosen country using the google api service. However, what you can do, is restrict google places auto complete to a specific country, by finding your country code (e.g. using this link https://countrycode.org/) and then adding the query to your google places api e.g.
components=country:your_country_code //Insert code into example
For example, this is what is would look like:
https://maps.googleapis.com/maps/api/place/autocomplete/json?
input=bhubaneshwar&components=country:in&sensor=false&key=your_key
If you are still interested, now it's possible to restrict the user's panning to a given area using the setLatLngBoundsForCameraTarget
method.
You will need to update the dependencies for your Play Services:
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}