Hi
I have been working on project that utilises the computed field module to get long/latitude then using the geocorder to reverse those coordinate to the actual address on the google map. With other field i have managed except computed field.
Please find attached error

Thank you

CommentFileSizeAuthor
error.png11.21 KBebal1
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ebal1’s picture

Issue summary: View changes
pcbudde’s picture

Can you share your code used in the computed field to reverse the coordinates?

ebal1’s picture

I having issue like this: https://www.drupal.org/node1970288/1970288.

$entity = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_lat_lon_fr_entity_')));
//$field_a = field_get_items($entity_type, $entity, 'field_lat_lon_fr_entity_');
$result =   db_query("SELECT field_grid_point_lat,field_grid_point_lon,entity_id 	FROM {field_data_field_grid_point} WHERE entity_id = $entity ");

 if ($result) {
    while ($row = $result->fetchAssoc()) {
      // Do something with:
     $lat =  $row['field_grid_point_lat'];
      $long =   $row['field_grid_point_lon'];
    }
  }
 $options = array();
  $options['language'] = "en";
 $address = geocoder_reverse("google", $lat, $long, $options);
if($address){
    //watchdog("DEBUG REVERSE GEOCODING", var_export($address, true));
    foreach ($address->data['geocoder_address_components'] as $component){
      if ($component->types[0] == 'country'){
        $country = $component->long_name;
        break;
      }
    }
  }

	
$entity_field[0]['value'] =  $country ;

Its does not create point for the country or point. What i have realised is that if a field is a computed field then its used in " Geocode from field" its does not work at work but for other field work ie title and body.

ebal1’s picture

@pcbudde even if just make something like this in :
$entity_field[0]['value'] = "POINT (-74.4602393 40.5169617)"; and its computed field , if you try to use Geocode from field to display that point nothing is showing up. I have spend sometimes on this

Simon Georges’s picture

ebal1’s picture

@Simon Georges I used that but still getting the same error

Simon Georges’s picture

Ok, thanks for the feedback.

ebal1’s picture

@Simon Georges i did used the patch that you suggested and follow the discussion threads, now i manage to get the geocorder working but for the first time when i create node its does not create the map, as soon as i edit it shows up everything successfully. I need to investigate the presave function.

Simon Georges’s picture

That's a start! If you find what's missing on geocoder's size, we'll commit a patch. Thanks for your feedback!

ebal1’s picture

Priority: Normal » Major
Simon Georges’s picture

Status: Active » Postponed (maintainer needs more info)
Pol’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)