Hi there

Thanks for a great module. I am using GMap array to embed my map within Drupal. When I click on the map, that marker shows up but what I ideally would like is to see the latitide and logitude in Decimal Degrees. Im assuming I have to create some sort of text field for latitude and Longitude and linking it to the Gmap. Any help will be appreciated. Thanks.

My code is as follows:

$mymap=array('id' => 'mymap',
  'latitude' => '-26.19258642226091',
  'longitude'=>' 30.17647933959961',
  'zoom' => 5,
  'width' => '600',
  'height' => '400px',
  'mtc' => 'standard',
  'type' => 'map',
 
'behavior' => array(
      'locpick' => TRUE,
      'nodrag' => FALSE,
      'nokeyboard' => TRUE,
      'overview' => FALSE,
      'scale' => TRUE,
    ),
  'markers' => array(
      array(
     'text' => 'First Marker',
     'markername' => 'small red',
         
  )),
);
echo theme('gmap', array('#settings' => $mymap));

Comments

OpenSourcer’s picture

I figured it out. See below in case this helps anyone.

CODE:



function initiation_page () {
  return drupal_get_form('initiation_form');
}



/**
 * Creating the actual form itself happens here
 
 */
function initiation_form ($form_state) {
  $form = array();
  
  $usegmap = (function_exists('gmap_set_location') && variable_get('location_usegmap', 1));

  if ($usegmap) {
    $form['map'] = array();  //reserve spot at top of form for map
  }

  $form['latitude'] = array(
      '#prefix' => '<div class="container-inline">',
      '#type' => 'textfield',
      '#title' => t('Latitude'),
      '#default_value' => isset($prefilled_values['latitude']) ? $prefilled_values['latitude'] : '',
      '#size' => 64,
      '#maxlength' => 64
      );
  $form['longitude'] = array(
      '#type' => 'textfield',
      '#title' => t('Longitude'),
      '#default_value' => isset($prefilled_values['longitude']) ? $prefilled_values['longitude'] : '',
      '#size' => 64,
      '#maxlength' => 64,
      '#description' => $description,
      '#suffix' => '</div>'
      );

  if ($usegmap) {

//can declare macro here or use array as shown below
//$map_macro = variable_get('gmap_user_map', '[gmap|id=usermap|center=0,30|zoom=16|width=100%|height=400px]');     
    
    
   $mymap=array('id' => 'mymap',
    'latitude' => '-25.165173368663943',
    'longitude' => '23.642578125',
    'zoom' => 3,
    'width' => '600',
    'height' => '400px',
    'mtc' => 'standard',
    'type' => 'map',
  
'behavior' => array(
      'locpick' => TRUE,
      'nodrag' => FALSE,
      'nokeyboard' => TRUE,
      'overview' => FALSE,
      'scale' => TRUE,
    ),
  'marker' => array(
     array(
    'latitude' => 0.000,
    'longitude' => 0.000,
        
  )),
);
         
    $form['map']['gmap']['#value'] = gmap_set_location($mymap, $form, array('latitude'=>'latitude','longitude'=>'longitude'));
  }
    
  return $form;
}


/**
* Return the form.
*/
return drupal_get_form('initiation_form');

afeijo’s picture

Thanks a lot! Your example solved my problem ;)

pjeutr’s picture

Great example, any idea how to add a zoom textfield?
I could write my own js Drupal.gmap.getMap('gmap-loc1-gmap0').map.setZoom(5);
But this being drupal, there must be an easier way!