Changeset 5

Show
Ignore:
Timestamp:
10/07/08 15:34:29 (3 years ago)
Author:
blundeln
Message:

Ha ha. It's all coming together now. Location aware-nodes now have a map that the user can click on to override the
location that google geocoding returned.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • drupal/modules/simple_maps/trunk/TODO

    r4 r5  
    1 - gmap api is hit and miss, so I need a manual override for the user 
    2 - view node should display static map 
    31- edit node should display dynamic map 
    42  - when moved, will override geocoded location of node. 
     3  - when blank will use address geocode. 
     4- view node should display static map 
  • drupal/modules/simple_maps/trunk/simple_maps.module

    r4 r5  
    7676} 
    7777 
     78function simple_maps_form_alter($form_id, &$form) {  
     79   
     80  /* Try to get the nid. */ 
     81  $nid = $form["nid"]["#value"]; 
     82  if (!$nid) { 
     83    return; 
     84  } 
     85 
     86  // Try to get location of node. 
     87  $loc = _get_node_location($nid); 
     88  if (!$loc) { 
     89    return; 
     90  } 
     91 
     92  // Look for the address field 
     93  $addressField = variable_get("simplemap.addressfield", "field_address"); 
     94 
     95  $form[] = _location_form($loc); 
     96 
     97  //d("form", $form[$addressField]); 
     98} 
    7899 
    79100/* Initialise the module. */ 
     
    84105} 
    85106 
     107 
     108function _location_form($loc) { 
     109  $form = array(); 
     110 
     111  $form['coordinates'] = array( 
     112    '#type' => 'fieldset', 
     113    '#title' => t('Location'), 
     114    '#weight' => 5, 
     115    '#collapsible' => $type!='user', 
     116    '#collapsed' => FALSE, 
     117  ); 
     118 
     119  // Reserve spot for map. 
     120  $form['coordinates']['gmap_node'] = array(); 
     121 
     122  $form['coordinates']['gmap_location_latitude'] = array( 
     123    '#type' => 'textfield', 
     124    '#title' => t('Latitude'), 
     125    '#default_value' => $loc['latitude'], 
     126    '#size' => 30, 
     127    '#maxlength' => 120, 
     128  ); 
     129 
     130  $form['coordinates']['gmap_location_longitude'] = array( 
     131    '#type' => 'textfield', 
     132    '#title' => t('Longitude'), 
     133    '#default_value' => $loc['longitude'], 
     134    '#size' => 30, 
     135    '#maxlength' => 120, 
     136    '#description' => t('The latitude and longitude will be entered here when you double-click on a location in the interactive map above. You can also fill in the values manually.'), 
     137  ); 
     138 
     139  $map = gmap_defaults(); 
     140  $map["width"] = "300px"; 
     141  $map["height"] = "300px"; 
     142 
     143  $form['coordinates']['gmap_node']['#value'] = gmap_set_location($map, $form['coordinates'], array('latitude' => 'gmap_location_latitude', 'longitude' => 'gmap_location_longitude')); 
     144 
     145  return $form; 
     146} 
    86147 
    87148/* 
     
    348409    $map["markers"] = $markers; 
    349410  } 
     411   
    350412  //d("",$map); 
    351413  $output .= theme('gmap', array('#settings' => $map));