How to create gmap coordinates programmatically in Drupal
If you have gmap and gmap content modules installed you can create a cck field of type GMaps Address and Point. To insert coordinates programmaticaly you can use the code from the function below. Deselect the "Enable bounds" check box in the edit content type - edit field. You can enable this afterwards when you finish whatever you were doing with your program, like importing nodes. The values for the address field do not have to match the values of the coordinates.
function update_geo_loc($record){
$id = (int) $record->nid;
$node = node_load($id);
//print_r($node);
$lat = 40.714269;
$lon = -74.005973;
// $node->field_geo_obsr[0]['value']->address->vid = $id;
// $node->field_geo_obsr[0]['value']->address->nid = $id;
$node->field_geo_obsr[0]['value']->address->field_name = 'field_geo_obsr';
// $node->field_geo_obsr[0]['value']->address->delta = 0;
$node->field_geo_obsr[0]['value']->address->country = 'FR';
$node->field_geo_obsr[0]['value']->address->adminarea = 'Île-de-France';
$node->field_geo_obsr[0]['value']->address->subadminarea = 'Paris';
$node->field_geo_obsr[0]['value']->address->locality = 'Paris';
// $node->field_geo_obsr[0]['value']->address->deplocality = NULL;
// $node->field_geo_obsr[0]['value']->address->postalcode = NULL;
// $node->field_geo_obsr[0]['value']->address->thoroughfare = NULL;
// $node->field_geo_obsr[0]['value']->address->privacy = 0;
// $node->field_geo_obsr[0]['value']->address->search = 'Toulouse, France';
// $node->field_geo_obsr[0]['value']->address->uid = 29;
$node->field_geo_obsr[0]['value']->point->latitude = $lat;
$node->field_geo_obsr[0]['value']->point->longitude = $lon;
$node->field_geo_obsr[0]['value']->point->elevation = 0;
$node->field_geo_obsr[0]['value']->point->map_type = 'earth';
// $node->field_geo_obsr[0]['value']->point->nid = $id;
// $node->field_geo_obsr[0]['value']->point->vid = $id;
// $node->field_geo_obsr[0]['value']->search = 'Toulouse, France';
// $node->field_geo_obsr[0][value]->point->bounds = array();
node_save($node);
}
