| 72 | | _set_node_geocode($node); |
|---|
| | 72 | // If box ticked, use fields to set this |
|---|
| | 73 | // else, re-geocode. |
|---|
| | 74 | if ($node->loc_manual_select and $node->loc_location_latitude and $node->loc_location_longitude) { |
|---|
| | 75 | $loc = _get_node_location($node->nid); |
|---|
| | 76 | $loc["latitude"] = $node->loc_location_latitude; |
|---|
| | 77 | $loc["longitude"] = $node->loc_location_longitude; |
|---|
| | 78 | $loc["manual"] = True; |
|---|
| | 79 | _set_node_location($node->nid, $loc); |
|---|
| | 80 | drupal_set_message("The geographic location of '$node->title' has been set manually."); |
|---|
| | 81 | //d("node",$node); |
|---|
| | 82 | } else { |
|---|
| | 83 | _geocode_node($node); |
|---|
| | 84 | $loc = _get_node_location($node->nid); |
|---|
| | 85 | $loc["manual"] = False; |
|---|
| | 86 | _set_node_location($node->nid, $loc); |
|---|
| | 87 | } |
|---|
| 108 | | function _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 | | } |
|---|
| | 187 | * FORMS |
|---|
| | 188 | * =============================== |
|---|
| | 189 | */ |
|---|
| | 190 | |
|---|
| | 191 | function _location_form($loc) { |
|---|
| | 192 | $form = array(); |
|---|
| | 193 | |
|---|
| | 194 | $form['coordinates'] = array( |
|---|
| | 195 | '#type' => 'fieldset', |
|---|
| | 196 | '#title' => t('Geographic Location'), |
|---|
| | 197 | '#weight' => 5, |
|---|
| | 198 | '#collapsible' => $type!='user', |
|---|
| | 199 | '#collapsed' => FALSE, |
|---|
| | 200 | ); |
|---|
| | 201 | |
|---|
| | 202 | // Reserve spot for map. |
|---|
| | 203 | $form['coordinates']['loc_manual_select'] = array( |
|---|
| | 204 | '#type' => 'checkbox', |
|---|
| | 205 | '#title' => t('Use manually selected location: Tick this box and click on the map to correct the location if it was not picked up automatically from the address.'), |
|---|
| | 206 | '#default_value' => $loc['manual'], |
|---|
| | 207 | ); |
|---|
| | 208 | |
|---|
| | 209 | $form['coordinates']['loc_node'] = array(); |
|---|
| | 210 | |
|---|
| | 211 | $form['coordinates']['loc_location_latitude'] = array( |
|---|
| | 212 | '#type' => 'hidden', |
|---|
| | 213 | '#title' => t('Latitude'), |
|---|
| | 214 | '#default_value' => $loc['latitude'], |
|---|
| | 215 | '#size' => 30, |
|---|
| | 216 | '#maxlength' => 120, |
|---|
| | 217 | ); |
|---|
| | 218 | |
|---|
| | 219 | $form['coordinates']['loc_location_longitude'] = array( |
|---|
| | 220 | '#type' => 'hidden', |
|---|
| | 221 | '#title' => t('Longitude'), |
|---|
| | 222 | '#default_value' => $loc['longitude'], |
|---|
| | 223 | '#size' => 30, |
|---|
| | 224 | '#maxlength' => 120, |
|---|
| | 225 | ); |
|---|
| | 226 | |
|---|
| | 227 | $map = gmap_defaults(); |
|---|
| | 228 | $map["width"] = "300px"; |
|---|
| | 229 | $map["height"] = "300px"; |
|---|
| | 230 | |
|---|
| | 231 | $form['coordinates']['loc_node']['#value'] = gmap_set_location($map, $form['coordinates'], array('latitude' => 'loc_location_latitude', 'longitude' => 'loc_location_longitude')); |
|---|
| | 232 | |
|---|
| | 233 | return $form; |
|---|
| | 234 | } |
|---|
| | 235 | |
|---|
| | 236 | /* |
|---|
| | 237 | * =============================== |
|---|