views:

118

answers:

1

Dear fellow Programmers, I try to use the following google map webservice in order to locate greek addresses: http://maps.google.com/maps/api/geocode/json?address=Ακαδημίας 16&sensor=false and it does not work. If I hit the same exactly address but written with latin alphabet characters: maps.google.com/maps/api/geocode/json?address=akadimias 16&sensor=false, it works and returns the right result. Could somebody help with this? (To use this service with greek letters as language parameter)

Thank you in advance,

Nicholas

A: 

You should encode the characters. In python you could do:

import urllib
address = 'Ακαδημίας'
encoded_address = urllib.quote(address)
query = 'http://maps.google.com/maps/api/geocode/json?address='+encoded_address+'&sensor=false'

As I am not familiar with greek I don't know if it should read 'Ακαδημίας' or 'Ακαδημίας 16', but the example above gives the encoded address to be

'%CE%91%CE%BA%CE%B1%CE%B4%CE%B7%CE%BC%CE%AF%CE%B1%CF%82'

and seems to work. I guess you have similar methods in PHP or whatever you want to use. For PHP have a look at Problem with greek url characters in IE

Hans