Pregunta

I am using google geocoder api

http://maps.googleapis.com/maps/api/geocode/json?address=dach&sensor=false

How can i set the accuracy for the gmap geocoding api to i.e. "only countries and cities"?

As an example, searching for "dach" currently i get the results:

  • Dalandstraße, 81927 Munic, Germany
  • Dacha, Kirovohradsaoblast, Ukraine
  • DA Lane, Deep Run, NC, 28525, USA

(which includes street names and stuff)

What i really want: (set a filter for only countries, places and cities)

  • Dachau, Germany
  • Dachstein, Austria

How can i set the geo filter to only return cities and countries?

¿Fue útil?

Solución

When you call the API, you can see, for each result, a type array, for example :

"types" : [ "route" ]

So, you will have to create your own filter to determine wich result(s) you're interesting in, depending of this types parameter.

You can find all the possible values of type here .

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top