Pregunta

I'm learning how to use google geocoding API in java. I've decided to use json format response, but faced some difficulties. An app should convert string address to latitude and longitude.

The example adress from google documentation (1600 Amphitheatre Parkway, Mountain View, CA) works just fine, but when I'm trying to request by adress in Cyrillic (for ex. 12 Пушкина, Москва), I get

INVALID_REQUEST

status.

I should notice, that the same request works fine in browser. So I wonder if there any way to request by Cyrillic address from java.

¿Fue útil?

Solución

You'll need to encode the address for use in a URL. I can't tell you which method to use in java(but I'm sure there is one).

In the end it should look like this:

http://maps.googleapis.com/maps/api/geocode/json?address=12%20%D0%9F%D1%83%D1%88%D0%BA%D0%B8%D0%BD%D0%B0%2C%20%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0&sensor=false

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