21 $form[
'study_location'] = array(
22 '#type' =>
'fieldset',
23 '#title' => t(
'<div class="fieldset-title">Study Location:</div>'),
25 '#collapsible' => TRUE,
26 '#description' => t(
'This should be the location(s) of your common garden, plantation, etc.'),
27 '#prefix' =>
'<div id="common-garden-loc">',
28 '#suffix' =>
'</div>',
31 $form[
'study_location'][
'type'] = array(
33 '#title' => t(
'Coordinate Projection: *'),
39 2 => t(
'Custom Location (brief description)'),
42 'callback' =>
'tpps_update_locations',
43 'wrapper' =>
'common-garden-loc',
45 '#attributes' => array(
46 'data-toggle' => array(
'tooltip'),
47 'data-placement' => array(
'right'),
48 'title' => array(
'Please select a Coordinate Projection, or select "Custom Location", to enter a custom study location'),
58 '#type' =>
'textfield',
59 '#title' =>
'Location !num: *',
63 $field[
'#description'] = t(
'Accepted formats: <br>Degrees Minutes Seconds: 41° 48\' 27.7" N, 72° 15\' 14.4" W<br>Degrees Decimal Minutes: 41° 48.462\' N, 72° 15.24\' W<br>Decimal Degrees: 41.8077° N, 72.2540° W<br>');
67 'label' =>
'Location',
68 'title' =>
'Study Location(s):',
69 'parents' => array(
'study_location'),
70 'callback' =>
'tpps_update_locations',
72 'wrapper' =>
'common-garden-loc',
73 'substitute_fields' => array(
78 $form[
'study_location'][
'locations'][
'#states'] = array(
80 ':input[name="study_location[type]"]' => array(
'value' =>
'0'),
84 if ($type != 2 and $type != 0) {
85 $form[
'study_location'][
'map-button'] = array(
87 '#title' =>
'Click here to update map',
88 '#value' =>
'Click here to update map',
89 '#button_type' =>
'button',
90 '#name' =>
'study_locations_map_button',
91 '#executes_submit_callback' => FALSE,
92 '#prefix' =>
'<div id="study_location_map">',
93 '#suffix' =>
'</div>',
95 'callback' =>
'tpps_study_location_map_ajax',
96 'wrapper' =>
'study_location_map',
103 if ($form_state[
'triggering_element'][
'#name'] ==
'study_locations_map_button' and $type != 2 and !empty($locs) and !empty($locs[
'number'])) {
105 $valid_coords = TRUE;
106 for ($i = 1; $i <= $locs[
'number']; $i++) {
107 if (empty($locs[$i])) {
108 $valid_coords = FALSE;
109 drupal_set_message(t(
'Location %num is required', array(
'%num' => $i)),
'error');
112 $raw_coord = $locs[$i];
114 if ($standard_coordinate) {
115 $parts = explode(
',', $standard_coordinate);
123 $valid_coords = FALSE;
124 drupal_set_message(t(
'Location %num: Invalid coordinates', array(
'%num' => $i)),
'error');
127 if (!empty($coords) and $valid_coords) {
128 $map_api_key = variable_get(
'tpps_maps_api_key', NULL);
129 $map_api_tools =
"<script src=\"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js\"></script><script src=\"https://maps.googleapis.com/maps/api/js?key=$map_api_key&callback=initMap\" 130 async defer></script>" 131 .
"<div id=\"_map_wrapper\"></div>";
132 drupal_add_js(array(
'tpps' => array(
'tree_info' => $coords)),
'setting');
133 drupal_add_js(array(
'tpps' => array(
'study_locations' => TRUE)),
'setting');
135 $form[
'study_location'][
'map-button'][
'#suffix'] = $map_api_tools;
155 $groups = &$options[
'pop_groups'];
156 $col = current($options[
'columns']);
157 if (array_search($row[$col], $groups) === FALSE) {
158 $groups[] = $row[$col];
tpps_standard_coord($raw_coordinate)
tpps_study_location(array &$form, array &$form_state)
tpps_accession_pop_groups($row, array &$options)