0

i need to get Longitude and Latitude from city name.
i search and test a lot of source code , but non of them helped me.

till i found this link :http://maps.googleapis.com/maps/api/geocode/json?address=تهران&sensor=false

so i try to get json from this URL
i try this source code

but output just shows “ZERO_RESULTS”

as you can see in first link i use a persian word : "تهران". If i use "tehran" instead of "تهران" output is correct.

here is my question: how can i use persian word in URL ?

UPDATE:
even i try to decode the address , but it does not help me! :(

alex
  • 8,904
  • 6
  • 49
  • 75
hassan moradnezhad
  • 455
  • 2
  • 6
  • 26

2 Answers2

0

try to call the same request with language=fa parameter:

http://maps.googleapis.com/maps/api/geocode/json?address=تهران&sensor=false&language=fa

alex
  • 8,904
  • 6
  • 49
  • 75
0

i found the problem

String encodedUrl1 = URLEncoder.encode(city,"UTF-8");

i must encode just city name and after encoded, use it in URL

"http://maps.googleapis.com/maps/api/geocode/json?address=" + encodedUrl1 + "&sensor=false"
hassan moradnezhad
  • 455
  • 2
  • 6
  • 26