iosgoogle-mapsmkmapview

Google MAP API http Request


I am making an iPhone app that enables users to search for a city/town/countries/states by keying in texts in a UISearchbar, I managed to get the reply from google via JSON. It works ok, but I have some unexpected replies for certain places.

When I search for, say, "Vietnam", "China", "Malaysia", "Indonesia" it gives 0 results. But when I search for, "Singapore", "Cambodia", then, it gives a result fine.

I don't get it, why does some countries aren't available as the search results?

Codes: The http request I sent is something like:

http://maps.google.com/maps/geo?q=%@?output=json

The %@ is a searchBar.text formatter.

So if I type Indonesia, basically the request becomes:

http://maps.google.com/maps/geo?q=Indonesia?output=json

Solution

  • Instead of using an undocumented output of maps.google.com, you should try using the Geocoding API:http://code.google.com/apis/maps/documentation/geocoding/#JSON Your query would be something like: http://maps.googleapis.com/maps/api/geocode/json?address=indonesia&sensor=false