Project

General

Profile

Revision 3eb8fbfb

ID3eb8fbfb958941e890bd4729b1c13a648542075e
Parent 14a1655f
Child d2fd2a4c

Added by Andreas Kohlbecker about 8 years ago

separating out map functionality in extra file

View differences:

.gitattributes
881 881
7.x/modules/cdm_dataportal/images/print_icon.gif -text
882 882
7.x/modules/cdm_dataportal/includes/common.inc -text
883 883
7.x/modules/cdm_dataportal/includes/descriptions.inc -text
884
7.x/modules/cdm_dataportal/includes/maps.inc -text
884 885
7.x/modules/cdm_dataportal/includes/media.inc -text
885 886
7.x/modules/cdm_dataportal/includes/occurrences.inc -text
886 887
7.x/modules/cdm_dataportal/includes/pages.inc -text
7.x/modules/cdm_dataportal/cdm_dataportal.module
24 24

  
25 25
module_load_include('inc', 'cdm_dataportal', 'includes/common');
26 26
module_load_include('inc', 'cdm_dataportal', 'includes/pages');
27
module_load_include('inc', 'cdm_dataportal', 'includes/media');
27
module_load_include('inc', 'cdm_dataportal', 'includes/media');
28
module_load_include('inc', 'cdm_dataportal', 'includes/maps');
28 29
module_load_include('inc', 'cdm_dataportal', 'includes/occurrences');
29 30
module_load_include('inc', 'cdm_dataportal', 'includes/descriptions');
30 31
module_load_include('inc', 'cdm_dataportal', 'includes/pre-drupal8');
......
110 111
}
111 112

  
112 113
function _add_js_openlayers() {
113
  $openlayers = '/js/OpenLayers-2.11/OpenLayers.js';
114

  
115
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . $openlayers, array(
116
      'type' => 'file',
117
      'weight' => JS_LIBRARY,
118
      'cache' => FALSE,
119
  ));
120
}
121

  
122
/**
123
 * @todo Please document this function.
124
 * @see http://drupal.org/node/1354
125
 */
126
function _add_js_openlayers_map() {
127

  
128
  _add_js_openlayers();
129

  
130
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/openlayers_map.js');
131

  
132
  $gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
133

  
134
  $baseLayers = variable_get('baselayers', array());
135
  if (!is_array($baseLayers) || count($baseLayers) == 0) {
136
    $baseLayers = array(
137
      'metacarta_vmap0' => 'Metacarta Vmap0',
138
      'PREFERRED' => 'metacarta_vmap0',
139
    );
140
  }
141
  $layerNames = '';
142
  foreach ($baseLayers as $layerName => $layerLabel) {
143
    if ($layerName == 'PREFERRED') {
144
      $preferredLayer = $baseLayers['PREFERRED'];
145
    }
146
    else {
147
      $layerNames .= ($layerNames ? ', ' : '') . "'$layerName'";
148
    }
149
  }
150

  
151
  if (isset($baseLayers['gmap']) || isset($baseLayers['gsat']) || isset($baseLayers['ghyb'])) {
152
    drupal_add_html_head('<script src=http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=' . $gmap_api_key . '" type="text/javascript"></script>', $key = NULL /* TODO Set this variable. */);
153
    drupal_add_js('http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1', array('type' => 'external'));
154
  }
155

  
156
  $edit_map_service = get_edit_map_service_settings();
157
  // window.onload - is executed when the document and images etc is fully loaded
158
  // Query(document).ready - is executed much earlier, when the DOM is loaded
159
  drupal_add_js("
160
          jQuery(document).ready(function() {
161

  
162
                window.onload = function () {
163
            // ---
164
                  jQuery('#openlayers_map').cdm_openlayers_map(
165
                   '" . $edit_map_service['base_uri'] . "',
166
                   '" . $edit_map_service['version'] . "',
167
                   {
168
                    legendPosition: 3,
169
                    displayWidth: '" . variable_get('cdm_dataportal_geoservice_display_width', FALSE) . "',
170
                    boundingBox: '" . variable_get('cdm_dataportal_geoservice_bounding_box', FALSE) . "',
171
                    distributionOpacity: '" . variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5') . "',
172
                    legendOpacity: '" . variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5') . "',
173
                    showLayerSwitcher: " . (variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE) ? 'true' : 'false') . ",
174
                    baseLayerNames: [" . $layerNames . "],
175
                    defaultBaseLayerName: '" . $preferredLayer . "'
176
                   }
177
                );
178
                 // ---
179
        };
180
      });
181
    ", array('type' => 'inline'));
114
  $openlayers = '/js/OpenLayers-2.11/OpenLayers.js';
182 115

  
116
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . $openlayers, array(
117
  'type' => 'file',
118
  'weight' => JS_LIBRARY,
119
  'cache' => FALSE,
120
  ));
183 121
}
184 122

  
185 123
/**
......
290 228
}
291 229

  
292 230

  
293
/**
294
 * @todo Enter description here ...
295
 *
296
 * @param unknown_type $width
297
 * @param unknown_type $bounding_box
298
 * @param unknown_type $occurrenceQuery
299
 * @param unknown_type $distributionQuery
300
 * @param unknown_type $legendFormatQuery
301
 * @param unknown_type $map_caption
302
 *
303
 * @return unknown
304
 */
305
function get_image_map($width, $bounding_box = FALSE, $occurrenceQuery = FALSE, $distributionQuery = FALSE, $legendFormatQuery = FALSE, $map_caption = FALSE) {
306

  
307
  // Additional query parameters as set in the data portal admin section.
308
  $labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
309

  
310
  $query_string = '&image=true&recalculate=false&legend=1&ms=' . $width
311
    . ($bounding_box ? '&bbox=' . $bounding_box : '')
312
    . ($labels_on ? '&label=' . $labels_on : '');
313

  
314
  if ($map_caption) {
315
    $query_string .= '&mlp=3&mc_s=Georgia,15,blue&mc=' . $map_caption;
316
  }
317

  
318
  if (get_edit_map_service_version_number() >= 1.1) {
319

  
320
    // Either occurrence or distribution - combined maps will be possible
321
    // in the future.
322
    if ($occurrenceQuery) {
323
      // @todo Fix $occurrenceQuery.
324
      $occurrenceQuery = str_replace("&image=false", "", $occurrenceQuery);
325
      // $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
326
      // Will be replaced below.. HACK!!!
327
      $occurrenceQuery .= '&l=tdwg4&as=';
328

  
329
      $query_string .= "&" . $occurrenceQuery;
330
    }
331
    elseif ($distributionQuery) {
332
      $query_string .= "&" . $distributionQuery;
333
    }
334

  
335
    // Apply Plain Image map settings special for version >= 1.1.
336
    /*
337
    example : title=a:Naturalized++non-invasive
338
    &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
339
    &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
340
    &mc_s=Georgia,15,blue&mc=&recalculate=false
341

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

  
349
    $map_service_script_name = "rest_gen.php";
350

  
351
    $bgcolor_areaStyleId = "y";
352
    $baselayer_areaStyleId = "z";
353
    $bgcolor_layer = '';
354
    $additional_area_styles = array();
355

  
356
    // Background color:
357
    if (variable_get('map_bg_color', '')) {
358
      $bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
359
      $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
360
    }
361

  
362
    // TODO HACK to replace the default base layer which currently is tdwg4 !!!
363
    // only needed for distribution maps.
364
    if (strpos($query_string, "?l=") !== FALSE) {
365
      $layer_param_token = "?l=";
366
    }
367
    else {
368
      $layer_param_token = "&l=";
369
    }
370
    if (strpos($query_string, "?as=") !== FALSE) {
371
      $areystyle_param_token = "?as=";
372
    }
373
    else {
374
      $areystyle_param_token = "&as=";
375
    }
376
    if (variable_get('map_base_layer', '')) {
377
      $query_string = str_replace($layer_param_token . "tdwg4", "$layer_param_token" . variable_get('map_base_layer', '') . ":" . $baselayer_areaStyleId, $query_string);
378
    }
379
    else {
380
      $query_string = str_replace($layer_param_token . "tdwg4", $layer_param_token . "tdwg4:" . $baselayer_areaStyleId . ",", $query_string);
381
    }
382

  
383
    if ($bgcolor_layer) {
384
      $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
385
    }
386

  
387
    if (variable_get('map_base_layer_style', '')) {
388
      $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
389
    }
390

  
391
    foreach ($additional_area_styles as $as) {
392
      $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
393
    }
394

  
395
  }
396
  else {
397
    // Pre 1.1. version of map service.
398
    if ($occurrenceQuery) {
399

  
400
      $map_service_script_name = "point.php";
401

  
402
      // Fix $occurrenceQuery.
403
      $occurrenceQuery = str_replace("&image=false", "", $occurrenceQuery);
404
      // $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
405
      $occurrenceQuery .= '&l=v:e_w_0';
406
      $query_string .= "&" . $occurrenceQuery;
407
    }
408
    elseif ($distributionQuery) {
409
      $query_string .= "&" . $distributionQuery;
410
      $map_service_script_name = "areas.php";
411
    }
412
  }
413

  
414
  $mapUri = url(get_edit_map_service_full_uri() . '/' . $map_service_script_name . '?' .  $query_string);
415
  $out = '<img class="distribution_map" src="' . $mapUri . '" alt="Map" />';
416
  // Showing map caption.
417
  if ($map_caption) {
418
    // FIXME: replace <br> by according css style.
419
    $out .= '<div class="distribution_map_caption">' . $map_caption . '</div>' . '<br />';
420
    $out .= '</div>';
421
  }
422

  
423
  return $out;
424
}
425

  
426
/**
427
 * @todo Enter description here ...
428
 *
429
 * @param unknown_type $width
430
 * @param unknown_type $bounding_box
431
 * @param unknown_type $occurrenceQuery
432
 * @param unknown_type $distributionQuery
433
 * @param unknown_type $legendFormatQuery
434
 * @param unknown_type $map_caption
435
 *
436
 * @return unknown
437
 */
438
function get_openlayers_map($width, $bounding_box = FALSE, $occurrenceQuery = FALSE, $distributionQuery = FALSE, $legendFormatQuery = FALSE, $map_caption = FALSE) {
439

  
440
  _add_js_openlayers_map();
441

  
442
  $out = '<div id="openlayers">';
443
  $out .= '<div id="openlayers_map" class="smallmap"';
444
  if($width) {
445
    $out .= ' style="width: ' . $width . 'px; height:' . ($width / 2) . 'px"';
446
  }
447

  
448
  // Additional query parameters as set in the data portal admin section.
449
  $labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
450

  
451
  $openlayers_map_query_string = '&img=false&ms=' . $width
452
    . ($bounding_box ? '&bbox=' . $bounding_box : '')
453
    . ($labels_on ? '&label=' . $labels_on : '');
454

  
455
  if ($occurrenceQuery) {
456
    // @todo Fix $occurrenceQuery.
457
//     $occurrenceQuery .= '&bbox=-180,-90,180,90';
458
    $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
459
    // $occurrenceQuery .= '&l=v:e_w_0';
460
    // TODO add to cdm service?
461
    $occurrenceQuery .= '&legend=0';
462

  
463
    $out .= ' occurrenceQuery="' . $occurrenceQuery . '&' . $openlayers_map_query_string . '"';
464
  }
465

  
466
  if ($distributionQuery) {
467
    $out .= ' distributionQuery="' . $distributionQuery . '&' . $openlayers_map_query_string . '"';
468
  }
469

  
470
  if ($legendFormatQuery) {
471
    $out .= ' legendFormatQuery="' . $legendFormatQuery . '"';
472
  }
473

  
474
  $out .= '></div></div>';
475

  
476
  // Showing map caption.
477
  if ($map_caption) {
478
    // FIXME: replace <br> by according css style.
479
    $out .= '<div class="distribution_map_caption">' . $map_caption . '</div>' . '<br />';
480
    $out .= '</div>';
481
  }
482
  return $out;
483
}
484

  
485 231
/* ====================== hook implementations ====================== */
486 232
/**
487 233
 * Implements hook_permission().
 *
7.x/modules/cdm_dataportal/includes/maps.inc
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
/**
21
 * @todo Please document this function.
22
 * @see http://drupal.org/node/1354
23
 */
24
function _add_js_openlayers_map() {
25

  
26
  _add_js_openlayers();
27

  
28
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/openlayers_map.js');
29

  
30
  $gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
31

  
32
  $baseLayers = variable_get('baselayers', array());
33
  if (!is_array($baseLayers) || count($baseLayers) == 0) {
34
    $baseLayers = array(
35
        'metacarta_vmap0' => 'Metacarta Vmap0',
36
        'PREFERRED' => 'metacarta_vmap0',
37
    );
38
  }
39
  $layerNames = '';
40
  foreach ($baseLayers as $layerName => $layerLabel) {
41
    if ($layerName == 'PREFERRED') {
42
      $preferredLayer = $baseLayers['PREFERRED'];
43
    }
44
    else {
45
      $layerNames .= ($layerNames ? ', ' : '') . "'$layerName'";
46
    }
47
  }
48

  
49
  if (isset($baseLayers['gmap']) || isset($baseLayers['gsat']) || isset($baseLayers['ghyb'])) {
50
    drupal_add_html_head('<script src=http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=' . $gmap_api_key . '" type="text/javascript"></script>', $key = NULL /* TODO Set this variable. */);
51
    drupal_add_js('http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1', array('type' => 'external'));
52
  }
53

  
54
  $edit_map_service = get_edit_map_service_settings();
55
  // window.onload - is executed when the document and images etc is fully loaded
56
  // Query(document).ready - is executed much earlier, when the DOM is loaded
57
  drupal_add_js("
58
          jQuery(document).ready(function() {
59

  
60
                window.onload = function () {
61
            // ---
62
                  jQuery('#openlayers_map').cdm_openlayers_map(
63
                   '" . $edit_map_service['base_uri'] . "',
64
                   '" . $edit_map_service['version'] . "',
65
                   {
66
                    legendPosition: 3,
67
                    displayWidth: '" . variable_get('cdm_dataportal_geoservice_display_width', FALSE) . "',
68
                    boundingBox: '" . variable_get('cdm_dataportal_geoservice_bounding_box', FALSE) . "',
69
                    distributionOpacity: '" . variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5') . "',
70
                    legendOpacity: '" . variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5') . "',
71
                    showLayerSwitcher: " . (variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE) ? 'true' : 'false') . ",
72
                    baseLayerNames: [" . $layerNames . "],
73
                    defaultBaseLayerName: '" . $preferredLayer . "'
74
                   }
75
                );
76
                 // ---
77
        };
78
      });
79
    ", array('type' => 'inline'));
80

  
81
}
82

  
83

  
84
/**
85
 * @todo Enter description here ...
86
 *
87
 * @param unknown_type $width
88
 * @param unknown_type $bounding_box
89
 * @param unknown_type $occurrenceQuery
90
 * @param unknown_type $distributionQuery
91
 * @param unknown_type $legendFormatQuery
92
 * @param unknown_type $map_caption
93
 *
94
 * @return unknown
95
 */
96
function get_openlayers_map($width, $bounding_box = FALSE, $occurrenceQuery = FALSE, $distributionQuery = FALSE, $legendFormatQuery = FALSE, $map_caption = FALSE) {
97

  
98
  _add_js_openlayers_map();
99

  
100
  $out = '<div id="openlayers">';
101
  $out .= '<div id="openlayers_map" class="smallmap"';
102
  if($width) {
103
    $out .= ' style="width: ' . $width . 'px; height:' . ($width / 2) . 'px"';
104
  }
105

  
106
  // Additional query parameters as set in the data portal admin section.
107
  $labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
108

  
109
  $openlayers_map_query_string = '&img=false&ms=' . $width
110
  . ($bounding_box ? '&bbox=' . $bounding_box : '')
111
  . ($labels_on ? '&label=' . $labels_on : '');
112

  
113
  if ($occurrenceQuery) {
114
    // @todo Fix $occurrenceQuery.
115
    //     $occurrenceQuery .= '&bbox=-180,-90,180,90';
116
    $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
117
    // $occurrenceQuery .= '&l=v:e_w_0';
118
    // TODO add to cdm service?
119
    $occurrenceQuery .= '&legend=0';
120

  
121
    $out .= ' occurrenceQuery="' . $occurrenceQuery . '&' . $openlayers_map_query_string . '"';
122
  }
123

  
124
  if ($distributionQuery) {
125
    $out .= ' distributionQuery="' . $distributionQuery . '&' . $openlayers_map_query_string . '"';
126
  }
127

  
128
  if ($legendFormatQuery) {
129
    $out .= ' legendFormatQuery="' . $legendFormatQuery . '"';
130
  }
131

  
132
  $out .= '></div></div>';
133

  
134
  // Showing map caption.
135
  if ($map_caption) {
136
    // FIXME: replace <br> by according css style.
137
    $out .= '<div class="distribution_map_caption">' . $map_caption . '</div>' . '<br />';
138
    $out .= '</div>';
139
  }
140
  return $out;
141
}
142

  
143

  
144

  
145
/**
146
 * @todo Enter description here ...
147
 *
148
 * @param unknown_type $width
149
 * @param unknown_type $bounding_box
150
 * @param unknown_type $occurrenceQuery
151
 * @param unknown_type $distributionQuery
152
 * @param unknown_type $legendFormatQuery
153
 * @param unknown_type $map_caption
154
 *
155
 * @return unknown
156
 */
157
function get_image_map($width, $bounding_box = FALSE, $occurrenceQuery = FALSE, $distributionQuery = FALSE, $legendFormatQuery = FALSE, $map_caption = FALSE) {
158

  
159
  // Additional query parameters as set in the data portal admin section.
160
  $labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
161

  
162
  $query_string = '&image=true&recalculate=false&legend=1&ms=' . $width
163
  . ($bounding_box ? '&bbox=' . $bounding_box : '')
164
  . ($labels_on ? '&label=' . $labels_on : '');
165

  
166
  if ($map_caption) {
167
    $query_string .= '&mlp=3&mc_s=Georgia,15,blue&mc=' . $map_caption;
168
  }
169

  
170
  if (get_edit_map_service_version_number() >= 1.1) {
171

  
172
    // Either occurrence or distribution - combined maps will be possible
173
    // in the future.
174
    if ($occurrenceQuery) {
175
      // @todo Fix $occurrenceQuery.
176
      $occurrenceQuery = str_replace("&image=false", "", $occurrenceQuery);
177
      // $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
178
      // Will be replaced below.. HACK!!!
179
      $occurrenceQuery .= '&l=tdwg4&as=';
180

  
181
      $query_string .= "&" . $occurrenceQuery;
182
    }
183
    elseif ($distributionQuery) {
184
      $query_string .= "&" . $distributionQuery;
185
    }
186

  
187
    // Apply Plain Image map settings special for version >= 1.1.
188
    /*
189
    example : title=a:Naturalized++non-invasive
190
    &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
191
    &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
192
    &mc_s=Georgia,15,blue&mc=&recalculate=false
193

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

  
201
    $map_service_script_name = "rest_gen.php";
202

  
203
    $bgcolor_areaStyleId = "y";
204
    $baselayer_areaStyleId = "z";
205
    $bgcolor_layer = '';
206
    $additional_area_styles = array();
207

  
208
    // Background color:
209
    if (variable_get('map_bg_color', '')) {
210
      $bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
211
      $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
212
    }
213

  
214
    // TODO HACK to replace the default base layer which currently is tdwg4 !!!
215
    // only needed for distribution maps.
216
    if (strpos($query_string, "?l=") !== FALSE) {
217
      $layer_param_token = "?l=";
218
    }
219
    else {
220
      $layer_param_token = "&l=";
221
    }
222
    if (strpos($query_string, "?as=") !== FALSE) {
223
      $areystyle_param_token = "?as=";
224
    }
225
    else {
226
      $areystyle_param_token = "&as=";
227
    }
228
    if (variable_get('map_base_layer', '')) {
229
      $query_string = str_replace($layer_param_token . "tdwg4", "$layer_param_token" . variable_get('map_base_layer', '') . ":" . $baselayer_areaStyleId, $query_string);
230
    }
231
    else {
232
      $query_string = str_replace($layer_param_token . "tdwg4", $layer_param_token . "tdwg4:" . $baselayer_areaStyleId . ",", $query_string);
233
    }
234

  
235
    if ($bgcolor_layer) {
236
      $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
237
    }
238

  
239
    if (variable_get('map_base_layer_style', '')) {
240
      $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
241
    }
242

  
243
    foreach ($additional_area_styles as $as) {
244
      $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
245
    }
246

  
247
  }
248
  else {
249
    // Pre 1.1. version of map service.
250
    if ($occurrenceQuery) {
251

  
252
      $map_service_script_name = "point.php";
253

  
254
      // Fix $occurrenceQuery.
255
      $occurrenceQuery = str_replace("&image=false", "", $occurrenceQuery);
256
      // $occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
257
      $occurrenceQuery .= '&l=v:e_w_0';
258
      $query_string .= "&" . $occurrenceQuery;
259
    }
260
    elseif ($distributionQuery) {
261
      $query_string .= "&" . $distributionQuery;
262
      $map_service_script_name = "areas.php";
263
    }
264
  }
265

  
266
  $mapUri = url(get_edit_map_service_full_uri() . '/' . $map_service_script_name . '?' .  $query_string);
267
  $out = '<img class="distribution_map" src="' . $mapUri . '" alt="Map" />';
268
  // Showing map caption.
269
  if ($map_caption) {
270
    // FIXME: replace <br> by according css style.
271
    $out .= '<div class="distribution_map_caption">' . $map_caption . '</div>' . '<br />';
272
    $out .= '</div>';
273
  }
274

  
275
  return $out;
276
}
277

  
278

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)