Search code examples
geocodinggoogle-geocoding-api

Google Geocoding API : Colombian Addresses issues / How to GeoCode Address intersections?


I'm using the Google GeoCodng API , I'm facing troubles trying to geocode addresses from Colombia,, for example 'Carrera 8 # 27 - 06, Santa Marta, MAD, CO', that address means ( Colombian notation) Street = Carrera 8 at 27 meters of Carrera 06... , The API results is a mid point of the City Santa Marta.

As an alternative, I want to ask for intersection of Carrera 8 and Carrera 06 ... but Are any way to ask for streets intersections in the Request?
something like Carrera 8 cross Carrera 06 ??

thanks, Any idea or suggestions would be great !!


Solution

  • If you can use a different API, this address format is supported much better by Place Autocomplete, with 2 caveats (details below). If you really need to use the Geocoding API, I suggest you report a bug about this.

    Caveat 1: The desired address may be different than you think. At least, as far as these address are supported by Place Autocomplete and Google Maps:

    • Carrera 8 # 27 - 06 (your query above) is interpreted as address 6 meters away from the intersection of Carrera 8 and Calle 27.
    • Carrera 8 # 6 - 27 interpreted as address 27 meters away from the intersection of Carrera 8 and Calle 6 (closer to your interpretation above).

    Caveat 2: Results are often better when removing blank spaces around the # and the numbers that follow it.

    With Blank spaces (Carrera 8 # 27 - 06): the result is "Carrera 8 #27" at 11.23607,-74.206259 (on the intersection).

    https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Carrera%208%20%23%2027%20-%2006,%20Santa%20Marta,%20MAD,%20CO

    description: "Carrera 8 #27, Comuna 1, Santa Marta, Magdalena, Colombia",
    place_id: "EjlDYXJyZXJhIDggIzI3LCBDb211bmEgMSwgU2FudGEgTWFydGEsIE1hZ2RhbGVuYSwgQ29sb21iaWEiMBIuChQKEglV0F19d_X0jhHxdnkgSY57xBABKhQKEgkRED6oevX0jhHJKMXdmInqZg",
    types: ["street_address","geocode"]
    

    Without Blank spaces (Carrera 8 #27-06) the result is "Carrera 8 #27-6" at 11.235968,-74.206502 (about 15 m. off the intersection).

    https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Carrera%208%20%2327-06,%20Santa%20Marta,%20MAD,%20CO

    description: "Carrera 8 #27-6, Comuna 1, Santa Marta, Magdalena, Colombia",
    place_id: "EjtDYXJyZXJhIDggIzI3LTYsIENvbXVuYSAxLCBTYW50YSBNYXJ0YSwgTWFnZGFsZW5hLCBDb2xvbWJpYSIwEi4KFAoSCafwXH139fSOEZgBlEk6gFM-EAYqFAoSCREQPqh69fSOEckoxd2Yiepm",
    types: ["street_address","geocode"]
    

    Make sure to URL-encode parameter values like input, because otherwise # breaks it:

    https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Carrera%208%20#%2027%20-%2006,%20Santa%20Marta,%20MAD,%20CO

    description: "Carrera 8, Cali, Valle del Cauca, Colombia",
    place_id: "EipDYXJyZXJhIDgsIENhbGksIFZhbGxlIGRlbCBDYXVjYSwgQ29sb21iaWEiLiosChQKEgmTf2JVTaYwjhFZP3nFcTrX2BIUChIJESedtkOmMI4R--NFJ63l3jc",
    types: ["route","geocode"]
    

    The result is a route (and not in Santa Marta) because the value of input is truncated to only the characters before the # character.