I am just learning the ropes with CartoDB and am curious to know if this is possible.

I have a CartoDB map with points and I am entering data into this map through the CartoDB editor.

I would like to be able to Google reverse geocode the street address of my point automatically.

Ideally I would create a link on the infowindow labeled 'Find address' this would then run a script which would find the address of that point and INSERT it into that points specified column on my table.

I would like this to run entirely from the CartoDB Editor as this is where I update my data from.

Does anyone know if this is possible and if so where is the best place to start?

If this won't work are there any other reverse Geocode solutions out there?

1 Answer 1


You could do it via a bit of Javascript coding, using CartoDB.js and Google Maps geocoder (not directly from the editor). I'll do something like this:

// The layer can be obtained via createLayer or createVis

layer.on('featureClick', function(e, latlng, pos, data, layer) {
  var geocoder = new google.maps.Geocoder();
    location: new google.maps.LatLng(data.lat, data.lng)

    function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var result = results[0], components = {};

              // Build address string
              $.each(result.address_components, function (index, value) {
                  if ($.inArray('street_number', value.types) !== -1) {
                      components.street_number = value.long_name ? (', ' + value.long_name) : '';

                  if ($.inArray('route', value.types) !== -1) {
                      components.address = value.long_name;
                  if ($.inArray('locality', value.types) !== -1) {
                      components.locality = value.long_name;
                  if ($.inArray('postal_code', value.types) !== -1) {
                      components.postal_code = value.long_name;

              if (!components.address) 
                 components.address = result.formatted_address;

              // Here, you could insert the point with the address using SQL API

        } else if (status == google.maps.GeocoderStatus.ZERO_RESULTS) {
            console.log('Error, address not found');

            // Handle error

        } else {
            // Handle error        

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.