how to restrict maps to only one country using google maps api for android

前端 未结 5 1207
深忆病人
深忆病人 2021-01-20 01:29

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

5条回答
  •  粉色の甜心
    2021-01-20 01:54

    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
    

提交回复
热议问题