Zied Hamdi
Zied Hamdi

Reputation: 2662

maps.googleapis result is different from maps.google.com

I have a very weired problem with maps: When I search maps.google.com for 'rue du sapin, la marsa, tunisie' it finds it and works as expected.

Now I'm using the Api and I configured it this way

private static final String MAPS_REQUEST_URL = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&language=FR&components=country:TN&address=";

When I request this url with 'rue du sapin, la marsa, tunisie' it returns Rue du Sapin, Carthago, Tunisie

I tried to play with the region, language, country parameters but nothing makes it work: it seams Google is translating la marsa to cartahago (in its internal version: which is geographically somehow correct, since la marsa is near carthago.

But nobody in Tunisia will call La marsa: carthago it's non sense.

So the question is: why does the web client use the good terms and the Api not?


Checking with chrome developer, (on the network tab), I have this request that is executed. I don't know how to translate it to the other api's url

curl 'https://maps.google.com/maps/suggest?q=rue+du+sapin,+la+mars&cp=21&hl=en&gl=&v=2&clid=1&json=a&ll=34.768691,10.008545&spn=5.955003,16.907959&vpsrc=6&authuser=0&auth=526fd0392GzY4pXSd2dS4DPzdNUGxkJ-kLI&src=1,2&num=5&numps=2&callback=_xdc_._1fhndbld0j' -H ':host: maps.google.com' -H 'accept-encoding: gzip,deflate,sdch' -H 'accept-language: en-US,en;q=0.8,fr;q=0.6,cs;q=0.4,it;q=0.2,ar;q=0.2' -H 'user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36' -H ':path: /maps/suggest?q=rue+du+sapin,+la+mars&cp=21&hl=en&gl=&v=2&clid=1&json=a&ll=34.768691,10.008545&spn=5.955003,16.907959&vpsrc=6&authuser=0&auth=526fd0392GzY4pXSd2dS4DPzdNUGxkJ-kLI&src=1,2&num=5&numps=2&callback=_xdc_._1fhndbld0j' -H 'accept: */*' -H ':version: HTTP/1.1' -H 'referer: https://maps.google.com/' -H 'cookie: SS=(...)' -H ':scheme: https' -H 'x-chrome-variations: CIO2yQEIhrbJAQiltskBCKm2yQEIxLbJAQiehsoBCNeHygEIlorKAQ==' -H ':method: GET' --compressed

It seams this answer is related to my problem (even though from far away) Google Map APIs : UK specific results


Thanks in advance for every answer

Upvotes: 2

Views: 4007

Answers (2)

Cybercartel
Cybercartel

Reputation: 12592

You can replace Carthago with La Marsa. Or pretend Google Maps gives the right geocode. Most likely the geocode from Google Maps api is correct and you overthink it?! To improve your accuracy you can search the geocode for different names:Google Maps API: Geocode returns different co-ordinates then Google maps but most likely it uses different databases:Google Maps Web site and API : different results. There is also the name and the address: Google Map geocoder not as accurate as a Google maps. How to parse the geocode:how to parse a Google Maps geocoding result.

Upvotes: 1

arkonautom
arkonautom

Reputation: 958

http://maps.googleapis.com/maps/api/geocode/json?sensor=true&language=EN&address=rue%20du%20sapin,%20la%20marsa (note sensor, language and nothing else apart from address) produces result set that contain all the data, "La Marsa Soukra" too.

One solution would be producing your own formatted_address from components you're receiving.

I hope you're having this problems with only one instance of location naming pair to filter ... yeah, I don't know what I'm talking about here ^^

~details right after the response

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Rue du Sapin",
               "short_name" : "Rue du Sapin",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Carthago",
               "short_name" : "Carthago",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "La Marsa Soukra",
               "short_name" : "La Marsa Soukra",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Tunis",
               "short_name" : "Tunis",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Tunisia",
               "short_name" : "TN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Rue du Sapin, Carthago, Tunisia",
         "geometry" : {
            ...
         },
         "partial_match" : true,
         "types" : [ "route" ]
      }
   ],
   "status" : "OK"
}

My guess is that

When loaded from maps.googleapis.com, the current implementation of the Maps API v3 does not rely on the exchange of cookies with Google.

is kicking in here somehow ... or just plain preference is given to component locality over administrative_area_level_2 ... as match is only partial with confidence:0.51319576424371627?

maps.google.com/maps/suggest isn't even something anybody should use (API not even documented properly, deprecated v2 used maps.google.com/maps/geo) and use some of all that more or less private data google has.

I played around with cp parameter in

http://maps.google.com/maps/suggest?q=rue+du+sapin,+la+marsa&cp=21&hl=en

and 20 produced quite interesting results.

Upvotes: 3

Related Questions