I'm using HTML5 Geolocation widget. I created also an address field for my content type.
I'd like that if a user didn't allow to give his position with HTML5, Geofield should take the coords from the address field.
I'm going to create a new module to do this (or I will use a rule), but I think it could be cool to have an option called "fallback widget" to determinate the value of Geofield if the principal widget is empty.
Thanks,
Fair

Comments

mErilainen’s picture

This would be great! In our case we might have the coordinates in a XML file, which the user can save when the address calculation is not precise, but when the coordinates are not available, then the address field is used to calculate the location.

mErilainen’s picture

Here something that works for me in a custom module for the problem I mentioned above.

<?php
// Checking if the coordinates are set, then updating the geo location
// to match the coordinates
function srv_site_node_presave($node) {
  if ($node->type == 'housing_company') {
    if (!geofield_field_is_empty($node->field_coordinates['und']['0'], 'field_coordinates')) {
      // Overriding location from coordinates
      $node->field_geo['und']['0'] = $node->field_coordinates['und']['0'];
    }
  }
}
?>

Both field_coordinates and field_geo are geofields. field_geo geocodes from another field, which is addressfield and field_coordinates gets the values directly from XML file through Feeds.

mtoscano’s picture

Version: 7.x-1.1 » 7.x-2.x-dev

It will be great to have this as a separate module with some customisation option.
In my case for example I am looking for a solution with a three case geocoding scenario:

  1. Image (exif file)
  2. OpenLayers Interactive Geocoding
  3. Address

each one as the fallback option if the previous are left blank.
Are you planning to convert this in a proper module?
Thanks

P.S. Moved to version 2 as OpenLayers Interactive Geocoding option has been included there.