Below is a segment of the code I'm using to embed a GMap map on a custom form I'm building for a module. I'm trying to have the lat and lon fields update from the user picking a location on the map but am not having a lot of luck. I have resorted to using gmap_set_location to build the map using that method, which works, but I'm keen to understand how I can use the gmap element to create the same functionality.

Any advice would be very welcome as the documentation for this is a little sparse (am happy to write up some docs on when I get this working!)

thanks

welly

$lat = '54.265224078605655';
$lon = '-2.98828125';

$map = gmap_parse_macro('[gmap ');
$map['id'] = 'loc_0';
$map['zoom'] = 4;
$map['latitude'] = $lat;
$map['longitude'] = $lon;
$map['behavior']['locpick'] = TRUE;
$map['behavior']['collapsehack'] = TRUE;

 $form['contact_us']['location_map'] = array(
  '#description' => t('Enter your location to be displayed as a Google map.'),
  '#type' => 'gmap',
  '#map' => $map['id'],
  '#gmap_settings' => $map,
);

$form['contact_us']['location_map_lat'] = array(
  '#description' => t('Enter your location to be displayed as a Google map.'),
  '#type' => 'gmap_latitude',
  '#map' => $map['id'],
  '#default_value' => $map['latitude'],
);

$form['contact_us']['location_map_lon'] = array(
  '#description' => t('Enter your location to be displayed as a Google map.'),
  '#type' => 'gmap_longitude',
  '#map' => $map['id'],
  '#default_value' => $map['longitude'],
);