Project

General

Profile

Download (21 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Functions for dealing maps
5
 *
6
 * @copyright
7
 *   (C) 2007-2013 EDIT
8
 *   European Distributed Institute of Taxonomy
9
 *   http://www.e-taxonomy.eu
10
 *
11
 *   The contents of this module are subject to the Mozilla
12
 *   Public License Version 1.1.
13
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14
 *
15
 * @author
16
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
17
 */
18

    
19
/**
20
 * Compose an render array for distribution and occurrence
21
 * maps.
22
 *
23
 * The map can either be a plain image or a dynamic open layers map
24
 * depending on the settings
25
 *
26
 * compose_hook() implementation
27
 *
28
 * @param $map_id
29
 * @param string $occurrence_query
30
 * @param $kml_request_url
31
 * @param string $distribution_query
32
 * @param string $legend_format_query
33
 * @param array $event_listeners
34
 *   An associative array of with OpenLayers.Map event names as key and corresponding js callbacks.
35
 *   In addition to the event names '#execute' as key is also allowed.
36
 *   Valid events are:
37
 *      - move
38
 *      - moveend
39
 *      - zoomend
40
 *      - changelayer
41
 *      - changebaselayer
42
 *      - #execute:
43
 *            force execution of the given callback after registration of the event handlers
44
 *   see http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.events for more
45
 * @param bool $resizable
46
 *    only possible for openlayers_map
47
 * @param string $force_map_type
48
 *   Can be used to override the map_type setting stored in the settings variable CDM_MAP_DISTRIBUTION
49
 *   - 1: openlayers_map
50
 *   - 0: image_map
51
 *
52
 * @return array A drupal render array
53
 * A drupal render array
54
 * @ingroup compose
55
 */
56
function compose_map($map_id, $occurrence_query = NULL, $kml_request_url, $distribution_query = NULL, $legend_format_query = NULL, array $event_listeners = [], $resizable = FALSE, $force_map_type = NULL) {
57

    
58
  $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
59

    
60
    if($force_map_type === NULL){
61
      $force_map_type = $map_settings['map_type'];
62
    }
63

    
64
    if ($force_map_type == 1) {
65
      _add_jquery_ui();
66
      $map_html = cdm_map_openlayers(
67
        $map_id,
68
        $occurrence_query,
69
        $kml_request_url,
70
        $distribution_query,
71
        $legend_format_query,
72
        $map_settings['caption'],
73
        $event_listeners,
74
        $resizable
75
      );
76
    }
77
     else {
78
      $map_height = round($map_settings['image_map']['width'] / (float)$map_settings['aspect_ratio']);
79
      $map_html = cdm_map_plain_image(
80
        $map_settings['image_map']['width'],
81
        $map_height,
82
        $occurrence_query,
83
        $distribution_query,
84
        $legend_format_query,
85
        $map_settings['caption']
86
      );
87
     }
88
  return markup_to_render_array($map_html);
89
}
90

    
91
/**
92
 * Adds the javascript for a openlayers map to the page as well as all javascript libs.
93
 *
94
 *
95
 * @param $map_id
96
 * @param $map_settings
97
 *   The map settings array as retrieved by e.g. get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
98
 * @param array $event_listeners
99
 *   An associative array of with OpenLayers.Map event names as key and corresponding js callbacks.
100
 *   In addition to the event names '#execute' as key is also allowed.
101
 *   Valid events are:
102
 *      - move
103
 *      - moveend
104
 *      - zoomend
105
 *      - changelayer
106
 *      - changebaselayer
107
 *      - #execute:
108
 *            force execution of the given callback after registration of the event handlers
109
 *   see http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.events for more
110
 * @param bool $resizable
111
 *   The map is made resizable when set to true
112
 */
113
function _add_js_openlayers_map($map_id, $map_settings, array $event_listeners = array(), $resizable = false) {
114

    
115
  font_awesome_icon_markup(); // no icon specified, only used to add the font and styles
116

    
117
  _add_js_openlayers();
118

    
119
  $edit_map_service = get_edit_map_service_settings();
120

    
121
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/map/openlayers_map.js',
122
    array(
123
      'type' => 'file',
124
      'group' => JS_DEFAULT, //  module-layer JavaScript.
125
      'weight' => 0,
126
      'cache' => TRUE,
127
      'preprocess' => FALSE
128
  ));
129
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/map/openlayers_layers.js',
130
    array(
131
      'type' => 'file',
132
      'group' => JS_DEFAULT,
133
       'weight' => 1, // after openlayers_map.js
134
      'cache' => TRUE,
135
      'preprocess' => FALSE
136
  ));
137

    
138
  $cdm_openlayers_options = array(
139
      'legendPosition'  => '3',
140
      'boundingBox' => $map_settings['bbox'],
141
      'maxZoom' => $map_settings['maxZoom'],
142
      'aspectRatio' => $map_settings['aspect_ratio'],
143
      'distributionOpacity' => $map_settings['distribution_opacity'],
144
      'legendOpacity' => $map_settings['legend']['opacity'],
145
      'showLayerSwitcher' => $map_settings['openlayers']['show_layer_switcher']  ==  1,
146
      'displayOutsideMaxExtent' => $map_settings['openlayers']['display_outside_max_extent'] == 1,
147
      'resizable' => $resizable,
148
      'specimenPageBaseUrl' => url('cdm_dataportal/occurrence'),
149
      'specimenLinkText' => custom_icon_font_markup('icon-interal-link-alt-solid')
150
//       'imgPath' => drupal_get_path('module', 'cdm_dataportal') . '/js/map/OpenLayers-2.13.1/img/' // path to the control icons
151
      // if no baseLayerNames or defaultBaseLayerName are not defined
152
      // the defaults in cdm_openlayers.js will be used
153
  );
154

    
155
  // --- setting the base layer options
156
  if (is_array($map_settings['openlayers']['base_layers']) && count($map_settings['openlayers']['base_layers']) > 0) {
157

    
158
    $base_layer_names = $map_settings['openlayers']['base_layers'];
159

    
160
    foreach($base_layer_names as $name){
161
      if(str_beginsWith($name, 'g')){
162
        if( isset($map_settings['openlayers']['google_maps_api_key']) && strlen($map_settings['openlayers']['google_maps_api_key']) == 39) {
163
          // google layer detected
164
          drupal_add_js("https://maps.googleapis.com/maps/api/js?key=" . $map_settings['openlayers']['google_maps_api_key'] . "&callback=initMap", 'external');
165
        } else {
166
          drupal_set_message('A Google Maps layer is configured but the API key is either missing or invalid. 
167
          Please set your Google Maps API key in the '  . l('Geo & Map Settings', 'admin/config/cdm_dataportal/settings/geo') .'.', 'warning');
168
        }
169
      }
170
    }
171

    
172
    // get default layer and remove the 'PREFERRED' from the list to avoid duplicate layers
173
    $preferred_baseLayer = $base_layer_names['PREFERRED'];
174
    unset($base_layer_names['PREFERRED']);
175

    
176
    $cdm_openlayers_options['baseLayerNames'] = array_values($base_layer_names);
177

    
178
    if($preferred_baseLayer){
179
      $cdm_openlayers_options['defaultBaseLayerName'] = $preferred_baseLayer;
180
      if(array_search($preferred_baseLayer, $cdm_openlayers_options['baseLayerNames']) === false){
181
        // the default layer must also  be in the list of base layers
182
        $cdm_openlayers_options['baseLayerNames'][] = $preferred_baseLayer;
183
      }
184
    }
185

    
186
  }
187

    
188
  // --- custom wms base layer
189
  $map_settings['openlayers']['custom_wms_base_layer']['params'] = json_decode($map_settings['openlayers']['custom_wms_base_layer']['params']);
190
  $cdm_openlayers_options['customWMSBaseLayerData'] = $map_settings['openlayers']['custom_wms_base_layer'];
191

    
192

    
193
  // --- wms_overlay_layer
194
  if(isset($map_settings['openlayers']['wms_overlay_layer']) && isset($map_settings['openlayers']['wms_overlay_layer']['is_enabled']) && $map_settings['openlayers']['wms_overlay_layer']['is_enabled']) {
195
    $map_settings['openlayers']['wms_overlay_layer']['params'] = json_decode($map_settings['openlayers']['wms_overlay_layer']['params']);
196
    $cdm_openlayers_options['wmsOverlayLayerData'] = $map_settings['openlayers']['wms_overlay_layer'];
197
  }
198

    
199
  // --- eventhandlers
200
  $event_listeners_js = '';
201
  $execute_handler = '';
202
  foreach($event_listeners as $event=>$js_callback){
203
    if($event == '#execute'){
204
      $execute_handler = 'map_container.each(function(){' . $js_callback . '();});';
205
    } else {
206
      $event_listeners_js .= ($event_listeners_js ? ",\n": "\n") .'"' . $event . '": ' . $js_callback;
207
    }
208
  }
209

    
210
  $mapserver_base_uri = $edit_map_service['base_uri'];
211
  $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
212
  $http_protocol = $is_https ? 'https' : 'http';
213
  $mapserver_base_uri = preg_replace('/^https?:/', $http_protocol . ':', $mapserver_base_uri);
214

    
215
  // window.onload - is executed when the document and images etc is fully loaded
216
  // Query(document).ready - is executed much earlier, when the DOM is loaded
217
  drupal_add_js("
218
          jQuery(document).ready(function() {
219
                jQuery(window).load(function () {
220
                  var map_container = jQuery('#openlayers-map-" . $map_id . "').cdm_openlayers_map(
221
                   '" . $mapserver_base_uri . "',
222
                   '" . $edit_map_service['version'] . "',
223
                   " .  json_encode($cdm_openlayers_options) . "
224
                );
225
                map_container.each(function(){
226
                        this.cdmOpenlayersMap.registerEvents({" . "
227
                        " . $event_listeners_js . "
228
                        });
229
                });
230
                " . $execute_handler . "
231
        });
232
      });
233
    ", array('type' => 'inline'));
234

    
235
}
236

    
237

    
238
/**
239
 * Creates markup for an openlayers based dynamic map.
240
 *
241
 * @param string $bounding_box
242
 * @param string $occurrenceQuery
243
 * @param string $kml_request_url
244
 * @param string $distributionQuery
245
 * @param string $legendFormatQuery
246
 * @param string $map_caption
247
 * @param array $event_listeners
248
 *   An associative array of with OpenLayers.Map event names as key and corresponding js callbacks.
249
 *   In addition to the event names '#execute' as key is also allowed.
250
 *   Valid events are:
251
 *      - move
252
 *      - moveend
253
 *      - zoomend
254
 *      - changelayer
255
 *      - changebaselayer
256
 *      - #execute:
257
 *            force execution of the given callback after registration of the event handlers
258
 *   see http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.events for more
259
 *
260
 * @return String
261
 *    The markup for the map
262
 */
263
function cdm_map_openlayers($map_id, $occurrenceQuery = FALSE, $kml_request_url = FALSE, $distributionQuery = FALSE,
264
                            $legendFormatQuery = FALSE, $map_caption = FALSE, array $event_listeners = array(),
265
                            $resizable = false) {
266

    
267
  $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
268

    
269
  if($map_id == NULL){
270
    $map_id = sha1($occurrenceQuery . $distributionQuery);
271
  }
272

    
273
  _add_js_openlayers_map($map_id, $map_settings, $event_listeners, $resizable);
274

    
275
  $out = '<div id="openlayers-container-' . $map_id . '" class="openlayers-container openlayers_width ui-widget-content" style="width: 100%;">';
276
  $out .= '<div id="openlayers-map-' . $map_id . '" class="smallmap" style="width:100%; height:100%; margin: 10px;"';
277

    
278
  // Additional query parameters as set in the data portal admin section.
279
  $labels_on = $map_settings['show_labels'];
280

    
281
  // need to set the ms parameter to some value in order to satisfy the
282
  // map service even if this value should not be required:
283
  $width = 512;
284

    
285
  $openlayers_map_query_string = '&img=false&ms=' . $width
286
  . ($labels_on ? '&label=' . $labels_on : '');
287

    
288
  if ($occurrenceQuery) {
289
    // @todo Fix $occurrenceQuery.
290
    //     $occurrenceQuery .= '&bbox=-180,-90,180,90';
291
    $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0'; // TODO why are we using v:atbi,e_w_0 as layer ???
292
    // $occurrenceQuery .= '&l=v:e_w_0';
293
    // TODO add to cdm service?
294
    $occurrenceQuery .= '&legend=0';
295

    
296
    $out .= ' data-occurrenceQuery="' . $occurrenceQuery . '&' . $openlayers_map_query_string . '"';
297
  }
298

    
299
  if ($distributionQuery) {
300
    //HACK for testing (this must be done in js)
301
//     $distributionQuery .= "&layer=em_tiny_jan2003&dest_projection_epsg=7777777";
302
    $out .= ' data-distributionQuery="' . $distributionQuery . '&' . $openlayers_map_query_string . '"';
303
  }
304

    
305
  if ($kml_request_url) {
306
    $out .= 'data-kml-request-url="' . $kml_request_url . '"';
307
  }
308

    
309

    
310
  if ($legendFormatQuery) {
311
    $out .= ' data-legendFormatQuery="' . $legendFormatQuery . '"';
312
  }
313

    
314
  $out .= '></div></div>';
315

    
316
  // Showing map caption.
317
  if ($map_caption) {
318
    $out .= '<div class="distribution_map_caption">' . $map_caption . '</div>';
319
  }
320
  return $out;
321
}
322

    
323

    
324
/**
325
 * Composes the render array for a distribution map using the given distribution query string.
326
 *
327
 * The distribution map can either be a plain image or a dynamic open layers map
328
 * depending on the settings.
329
 *
330
 * compose_hook() implementation
331
 *
332
 * @param string $query_string
333
 *    An EDIT map services distribution query string
334
 *
335
 * @return array
336
 *    A drupal render array
337
 *
338
 * Similar compose function compose_map()
339
 *
340
 * @ingroup compose
341
 */
342
function compose_distribution_map($query_string) {
343

    
344
  $fontStyles = array(
345
      0 => "plane",
346
      1 => "italic",
347
  );
348

    
349
  if (!$query_string) {
350
    // The $query_string is empty if there are no distribution areas defined.
351
    return null;
352
  }
353

    
354
  /* ------ choose the display mode, either openlayers or static image ------ */
355

    
356
  $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
357

    
358
  if ($map_settings['map_type'] == 1) {
359

    
360
    /* =========== display distributions using the openlayers map viewer =========== */
361

    
362
    $legendFormatQueryStr = "format=image" . urlencode('/') . "png"
363
      . "&TRANSPARENT=TRUE"
364
      . "&WIDTH=" . $map_settings['legend']['icon_width']
365
      . "&HEIGHT=" . $map_settings['legend']['icon_height']
366
      // TODO why is the layer=topp:tdwg_level_4 parameter needed at all here??
367
      // AK: i think the tdwg_level_4 is used as place holder and will be replaced later on
368
      // => search for "tdwg_level_4" in the code
369
      . "&layer=topp" . urlencode(':') . "tdwg_level_4"
370
      . "&LEGEND_OPTIONS=forceLabels" . urlencode(':') . "on"
371
      . ";fontStyle" . urlencode(':') . $fontStyles[$map_settings['legend']['font_style']]
372
      . ";fontSize" . urlencode(':') .  $map_settings['legend']['font_size']
373
      . "&SLD=";
374

    
375
    /*$out .= cdm_map_openlayers(
376
        $map_settings['bbox'],
377
        NULL,
378
        $query_string,
379
        $legendFormatQueryStr,
380
        $map_settings['caption']
381
    );
382
    */
383
  }
384
  else {
385
    $legendFormatQueryStr = '';
386
    /*
387
        cdm_map_plain_image(
388
            $map_settings['image_map']['width'],
389
            $map_settings['image_map']['height'],
390
            $map_settings['bbox'],
391
            NULL,
392
            $query_string,
393
            $legendFormatQueryStr,
394
            $map_settings['caption']
395
        );
396
    */
397
  }
398
  $out = compose_map('distribution', NULL, NULL, $query_string, $legendFormatQueryStr);
399

    
400
  return $out;
401
}
402

    
403
/**
404
 * Composes a map with the location points of the passed $type_designations.
405
 *
406
 * @param $type_designations
407
 *
408
 * @return array
409
 *     A drupal render array or an empty array in case there are no point to show.
410
 *
411
 * @ingroup compose
412
 */
413
function compose_type_designations_map($type_designations)
414
{
415
  $typedesignations_uuid_param = cdm_uuid_list_parameter_value($type_designations);
416
  $kml_request_uri = cdm_compose_url(CDM_WS_KML_TYPEDESIGNATIONS, array($typedesignations_uuid_param));
417
  $map_render_array = compose_map('specimens', null, $kml_request_uri, null, null, []);
418
  return $map_render_array;
419
}
420

    
421

    
422
/**
423
 * Composes the markup for a plain image map.
424
 *
425
 * @param int $width
426
 * @param string $occurrenceQuery
427
 * @param string $distributionQuery
428
 * @param string $legendFormatQuery
429
 * @param string $map_caption
430
 *
431
* @return String
432
 *    rendered html
433
 */
434
function cdm_map_plain_image($width, $height= NULL, $occurrenceQuery = FALSE, $distributionQuery = FALSE,
435
                             $legendFormatQuery = FALSE, $map_caption = FALSE) {
436

    
437
  $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
438

    
439
  $baselayer_name = $map_settings['image_map']['base_layer'];
440
  if(empty($baselayer_name)){
441
    $baselayer_name = "earth";
442
  }
443

    
444
  $query_string = '&img=true&recalculate=false&ms=' . $width . ($height ? ',' . $height : '')
445
  // Additional query parameters as set in the data portal admin section.
446
  . ($map_settings['bbox'] ? '&bbox=' . $map_settings['bbox'] : '')
447
  . ($map_settings['show_labels'] ? '&label=' . $map_settings['show_labels'] : '');
448

    
449
  if ($map_caption) {
450
    $query_string .= '&mlp=3&mc_s=Georgia,15,blue&mc=' . $map_caption;
451
  }
452

    
453
  if (get_edit_map_service_version_number() >= 1.1) {
454

    
455
    // Either occurrence or distribution - combined maps will be possible
456
    // in the future.
457
    if ($occurrenceQuery) {
458
      // @todo Fix $occurrenceQuery.
459
      $occurrenceQuery = str_replace("&image=false", "", $occurrenceQuery);
460
      // $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
461

    
462
      // Will be replaced below.. HACK!!!
463
      $occurrenceQuery .= '&l=' . $baselayer_name . '&as=';
464

    
465
      $query_string .= "&" . $occurrenceQuery;
466
    }
467
    elseif ($distributionQuery) {
468
      $query_string .= '&l=' . $baselayer_name . "&" .$distributionQuery;
469
    }
470

    
471
    // Apply Plain Image map settings special for version >= 1.1.
472
    /*
473
    example : title=a:Naturalized++non-invasive
474
    &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
475
    &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
476
    &mc_s=Georgia,15,blue&mc=&recalculate=false
477

    
478
    http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
479
    l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
480
    &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
481
    &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
482
    &mlp=3&ms=500&recalculate=false&title=a%3Aindigenous
483
    */
484

    
485
    $map_service_script_name = "rest_gen.php";
486

    
487
    $bgcolor_areaStyleId = "Y";
488
    $baselayer_areaStyleId = "Z";
489
    $bgcolor_layer = '';
490
    $additional_area_styles = array();
491

    
492
    // Background color:
493
    if ($map_settings['image_map']['bg_color'] ) {
494
      $bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
495
      $additional_area_styles[] = $bgcolor_areaStyleId . ":" . $map_settings['image_map']['bg_color'] . ",,";
496
    }
497

    
498
    // TODO HACK to replace the default base layer which currently is tdwg4 !!!
499
    // only needed for distribution maps.
500
    if (strpos($query_string, "?l=") !== FALSE) {
501
      $layer_param_token = "?l=";
502
    }
503
    else {
504
      $layer_param_token = "&l=";
505
    }
506
    if (strpos($query_string, "?as=") !== FALSE) {
507
      $areystyle_param_token = "?as=";
508
    }
509
    else {
510
      $areystyle_param_token = "&as=";
511
    }
512
    if ($map_settings['image_map']['base_layer']) {
513
      $query_string = str_replace($layer_param_token .$baselayer_name, "$layer_param_token" . $map_settings['image_map']['base_layer'] . ":" . $baselayer_areaStyleId, $query_string);
514
    }
515
    else {
516
      $query_string = str_replace($layer_param_token . $baselayer_name, $layer_param_token . $baselayer_name . ":" . $baselayer_areaStyleId . ",", $query_string);
517
    }
518

    
519
    if ($bgcolor_layer) {
520
      $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
521
    }
522

    
523
    if ($map_settings['image_map']['layer_style']) {
524
      $additional_area_styles[] = $baselayer_areaStyleId . ":" . $map_settings['image_map']['layer_style'];
525
    }
526

    
527
    if(isset($map_settings['projection'])){
528
      $query_string .= "&srs=" . $map_settings['projection'];
529
    }
530

    
531
    if(isset($map_settings['legend']['show']) && $map_settings['legend']['show']){
532
      $query_string .= "&legend=1";
533
    }
534

    
535
    foreach ($additional_area_styles as $as) {
536
      $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
537
    }
538

    
539
  }
540
  else {
541
    // Pre 1.1. version of map service.
542
    if ($occurrenceQuery) {
543

    
544
      $map_service_script_name = "point.php";
545

    
546
      // Fix $occurrenceQuery.
547
      $occurrenceQuery = str_replace("&image=false", "", $occurrenceQuery);
548
      // $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
549
      $occurrenceQuery .= '&l=v:e_w_0';
550
      $query_string .= "&" . $occurrenceQuery;
551
    }
552
    elseif ($distributionQuery) {
553
      $query_string .= "&" . $distributionQuery;
554
      $map_service_script_name = "areas.php";
555
    }
556
  }
557

    
558
  $mapUri = url(get_edit_map_service_full_uri() . '/' . $map_service_script_name . '?' .  $query_string);
559
  $out = '<img class="distribution_map" src="' . $mapUri . '" alt="Map" />';
560
  // Showing map caption.
561
  if ($map_caption) {
562
    $out .= '<div class="distribution_map_caption">' . $map_caption . '</div>';
563
  }
564

    
565
  return $out;
566
}
567

    
568
/**
569
 * @param $taxon
570
 * @return array
571
 */
572
function occurrence_map_query_parameters($taxon)
573
{
574
  $map_render_array = array();
575
  $occurrence_queryDto = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid, http_build_query(relationship_filter_query_parameters()));
576
  $kml_request_url = cdm_compose_url(CDM_WS_KML_TAXON_OCCURRENCE, array($taxon->uuid), http_build_query(relationship_filter_query_parameters()));
577

    
578
  $map_visibility = variable_get(SPECIMEN_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY_DEFAULT);
579
  if ($map_visibility == 'always' || $map_visibility == 'automatic' &&
580
    (isset($occurrence_queryDto->fieldUnitPoints[0]) || isset($occurrence_queryDto->derivedUnitPoints[0]))) {
581
    $occurrence_query = $occurrence_queryDto->occurrenceQuery;
582
    $legend_format_query = null;
583
    $distribution_query = NULL;
584
    $map_render_array = compose_map('specimens', NULL, $kml_request_url, $distribution_query, $legend_format_query, []);
585
  }
586
  return $map_render_array;
587
}
588

    
589

    
(4-4/13)