On a form I have that requests a location, I need it to populate the Latitude Longitude fields as well. I'm using the function google_geocode_location($location = array()) (from location module) to get the coordinates, but don't know how to get them to either
- Be Inserted at the Same Time (ideal solution)
- Be able to update after the insert -- I can't figure out how to examine the record and get the LID after the insert -- only have the info before the insert
The code I'm working with is below. I'm weeding out some unrelated code so I apologize if this has any gaping mistakes, I probably just removed too much.
/**
* Implements hook_form_alter
*/
function mobile_location_form_alter(&$form, &$form_state, $form_id){
if(substr($form_id, -10) == '_node_form'){
$form['#submit'][] = 'mobile_location_node_form_submit';
}
}
}
/**
* Handles receiving the coordinates of the location if called for.
* @param unknown_type $form
* @param unknown_type $form_state
*/
function mobile_location_node_form_submit(&$form, &$form_state){
module_load_include('inc', 'location', 'geocoding/google'); // Retrieve Address Geo-Encoder.
mobile_location_locationapi($form_state['values']['location']['und'], 'save');
}
function mobile_location_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) {