--- trackfield_map.module Thu Feb 05 04:23:34 2009 +++ trackfield_map.module Thu Mar 19 14:14:24 2009 @@ -53,7 +53,20 @@ '#title' => t('Reference Field Name'), '#default_value' => isset($field['reference_field_name']) ? $field['reference_field_name'] : '', '#required' => true - ) + ), + 'distance_marker_interval' => array( + '#type' => 'radios', + '#title' => t('Distance Markers'), + '#default_value' => isset($field['distance_marker_interval']) ? $field['distance_marker_interval'] : '', + '#options' => array(t('None'), t('km'), t('mi')), + ), + 'distance_marker_type' => array( + '#type' => 'select', + '#title' => t('Select the Distance Marker Type'), + '#default_value' => isset($field['distance_marker_type']) ? $field['distance_marker_type'] : '', + '#options' => gmap_get_marker_titles(), + '#description' => t('This is a list of GMap marker types, see the GMAP documentation to learn about adding custom markers.'), + ), ); return $form; case 'validate': @@ -66,7 +79,7 @@ } break; case 'save': - return array('reference_field_name'); + return array('reference_field_name','distance_marker_interval','distance_marker_type'); } } @@ -175,7 +188,7 @@ $ref_field_name = $field['reference_field_name']; $node = $element['#node']; $delta = 0; /* TODO: multiple deltas */ - $result = db_query("SELECT settype, setdata from {trackfield_datasets} WHERE vid = %d and field_name = '%s' and delta = %d and settype in ('latitude', 'longitude')", $node->vid, $ref_field_name, $delta); + $result = db_query("SELECT settype, setdata from {trackfield_datasets} WHERE vid = %d and field_name = '%s' and delta = %d and settype in ('latitude', 'longitude','distance')", $node->vid, $ref_field_name, $delta); while ($sd = db_fetch_object($result)) { $item[$sd->settype] = split(',', $sd->setdata); } @@ -188,6 +201,52 @@ $item['latitude'][0], $item['longitude'][0], $item['latitude'][$points - 1], $item['longitude'][$points - 1]); + /* + * Handles the setting of the distance markers + */ + // Check if the distance marker configuration is set + if ($field['distance_marker_interval']) { + // Set the distance interval based on the user's selection + if ($field['distance_marker_interval']==1) { + $distance_interval = 1000; //Set the distance markers to be 1km + } + elseif ($field['distance_marker_interval']==2) { + $distance_interval = 1609.344; //Set the distance markers to be 1mi + } + // Set the distance marker string based on the user's selection + if (isset($field['distance_marker_type'])) { + $distance_marker_type= $field['distance_marker_type']; + } + else { + $distance_marker_type = 'numbers'; + } + + $distance_marker[] = $item['latitude'][0] . ',' . $item['longitude'][0]; + // Check if the track length is greater than the interval to be plotted + if ($item['distance'][$points-1]>$distance_interval) { + // Loop through the entire track + for($lp = 1; $lp < $points; $lp++) { + // Check if any distance markers need to be plotted between the current track points + if (floor($item['distance'][$lp-1]/$distance_interval)nid", $trackfield_map_format_sizes[$formatter]['gmap_attr'], $path, + $distance_marker, $markers); _gmap_doheader();