hi,

i am trying to access location information (lat/lon) through computed field
because there where various formats in forums i searched
i tried every possible compination in case of wrong syntax
but i still cannot get it

if (!$node->nid) node_save($node);

echo $node->locations[0]['latitude']['value'] . ' , ' . 
$node->locations[0]['lat']['value'] . ' , ' . 
$node->locations[0]['latitude'] . ' , ' . 
$node->locations[0]['lat'] . ' , ' .
$node->locations['latitude'] . ' , ' . 
$node->locations['lat'] . ' , ' .
$node->location[0]['latitude']['value'] . ' , ' . 
$node->location[0]['lat']['value'] . ' , ' . 
$node->location[0]['latitude'] . ' , ' . 
$node->location[0]['lat'] . ' , ' .
$node->location['latitude'] . ' , ' . 
$node->location['lat'] . ' , ' ;

this returns , , , , , , , ...

is it something that has to do with computed field module or am i doing something wrong?

thanks!

Comments

emlomar1’s picture

Component: Miscellaneous » Code

I think it is a problem of the node_save function. This function deletes latitude and longitude values. I don't know why but it happens...

emlomar1’s picture

Actually I've discover that has something to do with the (location_geo_logic function in the location.module). This funcion allways sets lat and long to 0. To avoid that just edit the location.module and replace (line 1569 aprox.)

function _location_geo_logic(&$location, $changed, $filled, $inhibit_geocode = FALSE) {

  if (!$inhibit_geocode) {

with:

function _location_geo_logic(&$location, $changed, $filled, $inhibit_geocode = FALSE) {

  if (!$inhibit_geocode && !($location['latitude']!=0&&$location['longitude']!=0)) { //emlomar1

hope this helps.

farald’s picture

Status: Active » Fixed

Finally!

I saved the whole $node query to the database, and found out that location values is indeed not saved in $node->location[0][latitude]. BUT, the new latitudes are stored in following:

$node->locations[0][locpick][user_latitude];
$node->locations[0][locpick][user_longitude];

So, to manipulate the locations from computed field, use these:)
However, I do not know what other location fields are called. To find out, just put

<?php
$node_field[0]['value'] = var_export($node, TRUE);
?>

in your custom field.
Let it save to the db as a 'text' type, save a node, then go to phpmyadmin and inspect the array.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.