25 |
25 |
*
|
26 |
26 |
* compose_hook() implementation
|
27 |
27 |
*
|
|
28 |
* @param $map_id
|
28 |
29 |
* @param string $occurrence_query
|
29 |
30 |
* @param string $distribution_query
|
30 |
31 |
* @param string $legend_format_query
|
... | ... | |
46 |
47 |
* Can be used to override the map_type setting stored in the settings variable CDM_MAP_DISTRIBUTION
|
47 |
48 |
* - 1: openlayers_map
|
48 |
49 |
* - 0: image_map
|
49 |
|
*
|
50 |
|
* @return array
|
51 |
|
* A drupal render array
|
52 |
|
*
|
53 |
|
* Similar compose function compose_distribution_map()
|
54 |
|
*
|
|
50 |
* @return array A drupal render array
|
|
51 |
* A drupal render array
|
55 |
52 |
* @ingroup compose
|
56 |
53 |
*/
|
57 |
|
function compose_map($occurrence_query = NULL, $distribution_query = NULL,
|
58 |
|
$legend_format_query = NULL, array $event_listeners = array(), $resizable = false,
|
59 |
|
$force_map_type = NULL) {
|
|
54 |
function compose_map($map_id, $occurrence_query = NULL, $distribution_query = NULL, $legend_format_query = NULL, array $event_listeners = array(), $resizable = false, $force_map_type = NULL) {
|
60 |
55 |
|
61 |
56 |
$map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
|
62 |
57 |
|
... | ... | |
66 |
61 |
|
67 |
62 |
if ($force_map_type == 1) {
|
68 |
63 |
_add_jquery_ui();
|
69 |
|
$map_html = get_openlayers_map(
|
|
64 |
$map_html = cdm_map_openlayers(
|
|
65 |
$map_id,
|
70 |
66 |
$occurrence_query,
|
71 |
67 |
$distribution_query,
|
72 |
68 |
$legend_format_query,
|
73 |
69 |
$map_settings['caption'],
|
74 |
70 |
$event_listeners,
|
75 |
71 |
$resizable
|
76 |
|
);
|
|
72 |
);
|
77 |
73 |
}
|
78 |
74 |
else {
|
79 |
75 |
$map_height = round($map_settings['image_map']['width'] / (float)$map_settings['aspect_ratio']);
|
80 |
|
$map_html = get_image_map(
|
|
76 |
$map_html = cdm_map_plain_image(
|
81 |
77 |
$map_settings['image_map']['width'],
|
82 |
78 |
$map_height,
|
83 |
79 |
$occurrence_query,
|
... | ... | |
90 |
86 |
}
|
91 |
87 |
|
92 |
88 |
/**
|
|
89 |
* Adds the javascript for a openlayers map to the page as well as all javascript libs.
|
|
90 |
*
|
|
91 |
*
|
93 |
92 |
* @param $map_settings
|
94 |
93 |
* The map settings array as retrieved by e.g. get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
|
95 |
94 |
* @param array $event_listeners
|
... | ... | |
208 |
207 |
|
209 |
208 |
|
210 |
209 |
/**
|
211 |
|
* @todo Enter description here ...
|
|
210 |
* Creates markup for an openlayers based dynamic map.
|
212 |
211 |
*
|
213 |
212 |
* @param string $bounding_box
|
214 |
213 |
* @param string $occurrenceQuery
|
... | ... | |
229 |
228 |
* see http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.events for more
|
230 |
229 |
*
|
231 |
230 |
* @return String
|
232 |
|
* rendered html
|
|
231 |
* The markup for the map
|
233 |
232 |
*/
|
234 |
|
function get_openlayers_map($occurrenceQuery = FALSE, $distributionQuery = FALSE,
|
|
233 |
function cdm_map_openlayers($map_id, $occurrenceQuery = FALSE, $distributionQuery = FALSE,
|
235 |
234 |
$legendFormatQuery = FALSE, $map_caption = FALSE, array $event_listeners = array(),
|
236 |
235 |
$resizable = false) {
|
237 |
236 |
|
238 |
237 |
$map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
|
239 |
238 |
|
|
239 |
if($map_id == NULL){
|
|
240 |
$map_id = "openlayers-container-" . sha1($occurrenceQuery . $distributionQuery);
|
|
241 |
}
|
|
242 |
|
240 |
243 |
_add_js_openlayers_map($map_settings, $event_listeners, $resizable);
|
241 |
244 |
|
242 |
|
$out = '<div id="openlayers_container" class="openlayers_width ui-widget-content" style="width: 100%;">';
|
|
245 |
$out = '<div id="' . $map_id . '" class="openlayers-container openlayers_width ui-widget-content" style="width: 100%;">';
|
243 |
246 |
$out .= '<div id="openlayers_map" class="smallmap" style="width:100%; height:100%; margin: 10px;"';
|
244 |
247 |
|
245 |
248 |
// Additional query parameters as set in the data portal admin section.
|
... | ... | |
284 |
287 |
|
285 |
288 |
|
286 |
289 |
/**
|
287 |
|
* Composes the render array for a distribution map of the given taxon.
|
|
290 |
* Composes the render array for a distribution map using the given distribution query string.
|
288 |
291 |
*
|
289 |
292 |
* The distribution map can either be a plain image or a dynamic open layers map
|
290 |
293 |
* depending on the settings.
|
291 |
294 |
*
|
292 |
295 |
* compose_hook() implementation
|
293 |
296 |
*
|
294 |
|
* @param $taxon
|
295 |
|
* The CDM Taxon instance to create the distribution map for.
|
|
297 |
* @param string $query_string
|
|
298 |
* An EDIT map services distribution query string
|
|
299 |
*
|
296 |
300 |
* @return array
|
297 |
301 |
* A drupal render array
|
298 |
302 |
*
|
... | ... | |
300 |
304 |
*
|
301 |
305 |
* @ingroup compose
|
302 |
306 |
*/
|
303 |
|
function compose_distribution_map($taxon, $query_string) {
|
304 |
|
|
305 |
|
$out = '';
|
|
307 |
function compose_distribution_map($query_string) {
|
306 |
308 |
|
307 |
309 |
$fontStyles = array(
|
308 |
310 |
0 => "plane",
|
... | ... | |
335 |
337 |
. ";fontSize" . urlencode(':') . $map_settings['legend']['font_size']
|
336 |
338 |
. "&SLD=";
|
337 |
339 |
|
338 |
|
/*$out .= get_openlayers_map(
|
|
340 |
/*$out .= cdm_map_openlayers(
|
339 |
341 |
$map_settings['bbox'],
|
340 |
342 |
NULL,
|
341 |
343 |
$query_string,
|
... | ... | |
347 |
349 |
else {
|
348 |
350 |
$legendFormatQueryStr = '';
|
349 |
351 |
/*
|
350 |
|
get_image_map(
|
|
352 |
cdm_map_plain_image(
|
351 |
353 |
$map_settings['image_map']['width'],
|
352 |
354 |
$map_settings['image_map']['height'],
|
353 |
355 |
$map_settings['bbox'],
|
... | ... | |
358 |
360 |
);
|
359 |
361 |
*/
|
360 |
362 |
}
|
361 |
|
$out = compose_map(NULL, $query_string, $legendFormatQueryStr);
|
|
363 |
$out = compose_map(NULL, NULL, $query_string, $legendFormatQueryStr);
|
362 |
364 |
|
363 |
365 |
return $out;
|
364 |
366 |
}
|
... | ... | |
367 |
369 |
|
368 |
370 |
|
369 |
371 |
/**
|
370 |
|
* @todo Enter description here ...
|
|
372 |
* Composes the markup for a plain image map.
|
371 |
373 |
*
|
372 |
|
* @param unknown_type $width
|
373 |
|
* @param unknown_type $occurrenceQuery
|
374 |
|
* @param unknown_type $distributionQuery
|
375 |
|
* @param unknown_type $legendFormatQuery
|
376 |
|
* @param unknown_type $map_caption
|
|
374 |
* @param int $width
|
|
375 |
* @param string $occurrenceQuery
|
|
376 |
* @param string $distributionQuery
|
|
377 |
* @param string $legendFormatQuery
|
|
378 |
* @param string $map_caption
|
377 |
379 |
*
|
378 |
380 |
* @return String
|
379 |
381 |
* rendered html
|
380 |
382 |
*/
|
381 |
|
function get_image_map($width, $height= NULL, $occurrenceQuery = FALSE, $distributionQuery = FALSE,
|
382 |
|
$legendFormatQuery = FALSE, $map_caption = FALSE) {
|
|
383 |
function cdm_map_plain_image($width, $height= NULL, $occurrenceQuery = FALSE, $distributionQuery = FALSE,
|
|
384 |
$legendFormatQuery = FALSE, $map_caption = FALSE) {
|
383 |
385 |
|
384 |
386 |
$map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
|
385 |
387 |
|
maps documentation, refactoring of unused params etc, unique map container ids