commit 669f08ee073432d163976f10b59f1d516e71f827
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Mon Nov 28 13:39:43 2016 +0100

    fix #5938 unique ids for each openlayers block elements

diff --git a/modules/cdm_dataportal/includes/maps.inc b/modules/cdm_dataportal/includes/maps.inc
index dac9c924..71a31437 100644
--- a/modules/cdm_dataportal/includes/maps.inc
+++ b/modules/cdm_dataportal/includes/maps.inc
@@ -89,6 +89,7 @@ function compose_map($map_id, $occurrence_query = NULL, $distribution_query = NU
  * Adds the javascript for a openlayers map to the page as well as all javascript libs.
  *
  *
+ * @param $map_id
  * @param $map_settings
  *   The map settings array as retrieved by e.g. get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
  * @param array $event_listeners
@@ -106,7 +107,7 @@ function compose_map($map_id, $occurrence_query = NULL, $distribution_query = NU
  * @param bool $resizable
  *   The map is made resizable when set to true
  */
-function _add_js_openlayers_map($map_settings, array $event_listeners = array(), $resizable = false) {
+function _add_js_openlayers_map($map_id, $map_settings, array $event_listeners = array(), $resizable = false) {
 
   font_awesome_icon_markup(); // no icon specified, only used to add the font and styles
 
@@ -200,7 +201,7 @@ function _add_js_openlayers_map($map_settings, array $event_listeners = array(),
   drupal_add_js("
           jQuery(document).ready(function() {
                 jQuery(window).load(function () {
-                  var map_container = jQuery('#openlayers_map').cdm_openlayers_map(
+                  var map_container = jQuery('#openlayers-map-" . $map_id . "').cdm_openlayers_map(
                    '" . $mapserver_base_uri . "',
                    '" . $edit_map_service['version'] . "',
                    " .  json_encode($cdm_openlayers_options) . "
@@ -249,13 +250,13 @@ function cdm_map_openlayers($map_id, $occurrenceQuery = FALSE, $distributionQuer
   $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
 
   if($map_id == NULL){
-    $map_id = "openlayers-container-" . sha1($occurrenceQuery . $distributionQuery);
+    $map_id = sha1($occurrenceQuery . $distributionQuery);
   }
 
-  _add_js_openlayers_map($map_settings, $event_listeners, $resizable);
+  _add_js_openlayers_map($map_id, $map_settings, $event_listeners, $resizable);
 
-  $out = '<div id="' . $map_id . '" class="openlayers-container openlayers_width ui-widget-content" style="width: 100%;">';
-  $out .= '<div id="openlayers_map" class="smallmap" style="width:100%; height:100%; margin: 10px;"';
+  $out = '<div id=""openlayers-container-' . $map_id . '" class="openlayers-container openlayers_width ui-widget-content" style="width: 100%;">';
+  $out .= '<div id="openlayers-map-' . $map_id . '" class="smallmap" style="width:100%; height:100%; margin: 10px;"';
 
   // Additional query parameters as set in the data portal admin section.
   $labels_on = $map_settings['show_labels'];
diff --git a/modules/cdm_dataportal/js/map/openlayers_map.js b/modules/cdm_dataportal/js/map/openlayers_map.js
index 5dfd1e15..f601fbb4 100644
--- a/modules/cdm_dataportal/js/map/openlayers_map.js
+++ b/modules/cdm_dataportal/js/map/openlayers_map.js
@@ -432,67 +432,67 @@
          */
         var initMap = function(){
 
-            if(opts.showLayerSwitcher === true){
-                defaultControls.push(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
-            }
+          if(opts.showLayerSwitcher === true){
+              defaultControls.push(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
+          }
 
-            // defaultControls.unshift(layerLoadingControl()); // as first control, needs to be below all others!
+          // defaultControls.unshift(layerLoadingControl()); // as first control, needs to be below all others!
 
 //          var maxExtentByAspectRatio = cropBoundsToAspectRatio(defaultBaseLayer.maxExtent, getWidth/getHeight);
-            var maxResolution = null;
-            // gmaps has no maxExtent at this point, need to check for null
-            if(defaultBaseLayer.maxExtent != null){
-                maxResolution = Math[(opts.displayOutsideMaxExtent ? 'max' : 'min')](
-                        defaultBaseLayer.maxExtent.getWidth() / getWidth(),
-                        defaultBaseLayer.maxExtent.getHeight() / getHeight()
-                );
-            }
-            console.log("mapOptions.maxResolution: " + maxResolution);
-            console.log("mapOptions.restrictedExtent: " + defaultBaseLayer.maxExtent);
-
-            map = new OpenLayers.Map(
-                    "openlayers_map",
-                    {
-                        // defines the map ui elements and interaction features
-                        controls: defaultControls,
-
-                        // maxResolution determines the lowest zoom level and thus places the map
-                        // in its maximum extent into the available view port so that no additinal
-                        // gutter is visible and no parts of the map are hidden
-                        // see http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels
-                        // IMPORTANT!!!
-                        // the maxResulution set here will be overwritten if the baselayers maxResolution
-                        // it is set
-                        maxResolution: maxResolution,
-
-                        // setting restrictedExtent the the maxExtent prevents from panning the
-                        // map out of its bounds
-                        restrictedExtent: defaultBaseLayer.maxExtent,
+          var maxResolution = null;
+          // gmaps has no maxExtent at this point, need to check for null
+          if(defaultBaseLayer.maxExtent != null){
+              maxResolution = Math[(opts.displayOutsideMaxExtent ? 'max' : 'min')](
+                      defaultBaseLayer.maxExtent.getWidth() / getWidth(),
+                      defaultBaseLayer.maxExtent.getHeight() / getHeight()
+              );
+          }
+          console.log("mapOptions.maxResolution: " + maxResolution);
+          console.log("mapOptions.restrictedExtent: " + defaultBaseLayer.maxExtent);
+
+          map = new OpenLayers.Map(
+            mapElement.attr('id'),
+            {
+              // defines the map ui elements and interaction features
+              controls: defaultControls,
+
+              // maxResolution determines the lowest zoom level and thus places the map
+              // in its maximum extent into the available view port so that no additinal
+              // gutter is visible and no parts of the map are hidden
+              // see http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels
+              // IMPORTANT!!!
+              // the maxResulution set here will be overwritten if the baselayers maxResolution
+              // it is set
+              maxResolution: maxResolution,
+
+              // setting restrictedExtent the the maxExtent prevents from panning the
+              // map out of its bounds
+              restrictedExtent: defaultBaseLayer.maxExtent,
 //                      maxExtent: defaultBaseLayer.maxExtent,
 
-                        // Setting the map.fractionalZoom property to true allows zooming to an arbitrary level
-                        // (between the min and max resolutions).
-                        // fractional tiles are not supported by XYZ layers like OSM so this option would
-                        // break the tile retrieval for OSM (e.g.: tile for fractional zoom level
-                        // 1.2933333333333332 = http://b.tile.openstreetmap.org/1.2933333333333332/1/0.png)
-                        fractionalZoom: defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.OSM" && defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.XYZ",
+              // Setting the map.fractionalZoom property to true allows zooming to an arbitrary level
+              // (between the min and max resolutions).
+              // fractional tiles are not supported by XYZ layers like OSM so this option would
+              // break the tile retrieval for OSM (e.g.: tile for fractional zoom level
+              // 1.2933333333333332 = http://b.tile.openstreetmap.org/1.2933333333333332/1/0.png)
+              fractionalZoom: defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.OSM" && defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.XYZ",
 
-                        eventListeners: opts.eventListeners,
-                        // creating the map with a null theme, since we include the stylesheet directly in the page
-                        theme: null
+              eventListeners: opts.eventListeners,
+              // creating the map with a null theme, since we include the stylesheet directly in the page
+              theme: null
 
-                    }
-            );
+            }
+          );
 
-            //add the base layers
+          //add the base layers
 
-            addLayers(baseLayers);
-            map.setBaseLayer(defaultBaseLayer);
+          addLayers(baseLayers);
+          map.setBaseLayer(defaultBaseLayer);
 
-            // calculate the bounds to zoom to
-            zoomToBounds = zoomToBoundsFor(opts.boundingBox ? opts.boundingBox : defaultBaseLayerBoundingBox, defaultBaseLayer);
-            zoomToBounds = cropBoundsToAspectRatio(zoomToBounds, map.getSize().w / map.getSize().h);
-            console.log("baselayer zoomToBounds: " + zoomToBounds);
+          // calculate the bounds to zoom to
+          zoomToBounds = zoomToBoundsFor(opts.boundingBox ? opts.boundingBox : defaultBaseLayerBoundingBox, defaultBaseLayer);
+          zoomToBounds = cropBoundsToAspectRatio(zoomToBounds, map.getSize().w / map.getSize().h);
+          console.log("baselayer zoomToBounds: " + zoomToBounds);
 
         };
 
diff --git a/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java b/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java
index d1d6ea9a..81fec3db 100644
--- a/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java
+++ b/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java
@@ -146,7 +146,7 @@ public class Lactuca_triquetra_TaxonProfileTest extends CdmDataPortalTestBase{
             assertEquals("Expecting 7 Footnotes", 7, featureBlock.countFootNotes());
         }
 
-        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
+        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers-map-distribution")));
         WebElement mapCaptionElement = null;
         try {
             mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
diff --git a/src/test/java/eu/etaxonomy/dataportal/selenium/tests/palmae/Calamus_acanthospathus_TaxonProfileTest.java b/src/test/java/eu/etaxonomy/dataportal/selenium/tests/palmae/Calamus_acanthospathus_TaxonProfileTest.java
index f6b11d7c..bda081c7 100644
--- a/src/test/java/eu/etaxonomy/dataportal/selenium/tests/palmae/Calamus_acanthospathus_TaxonProfileTest.java
+++ b/src/test/java/eu/etaxonomy/dataportal/selenium/tests/palmae/Calamus_acanthospathus_TaxonProfileTest.java
@@ -108,7 +108,7 @@ public class Calamus_acanthospathus_TaxonProfileTest extends CdmDataPortalTestBa
         assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "World Checklist of Monocotyledons", this.getContext().getBaseUri().toString()));
         assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(1).getLinksInElement().get(0), "T. Evans et al. 2002", this.getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
 
-        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
+        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers-map-distribution")));
         assertEquals("Map accurate to TDWG level 3 distributions", featureBlock.getElement().findElement(By.className("distribution_map_caption")).getText());
 
 
