Project

General

Profile

« Previous | Next » 

Revision 669f08ee

Added by Andreas Kohlbecker over 7 years ago

fix #5938 unique ids for each openlayers block elements

View differences:

modules/cdm_dataportal/js/map/openlayers_map.js
432 432
         */
433 433
        var initMap = function(){
434 434

  
435
            if(opts.showLayerSwitcher === true){
436
                defaultControls.push(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
437
            }
435
          if(opts.showLayerSwitcher === true){
436
              defaultControls.push(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
437
          }
438 438

  
439
            // defaultControls.unshift(layerLoadingControl()); // as first control, needs to be below all others!
439
          // defaultControls.unshift(layerLoadingControl()); // as first control, needs to be below all others!
440 440

  
441 441
//          var maxExtentByAspectRatio = cropBoundsToAspectRatio(defaultBaseLayer.maxExtent, getWidth/getHeight);
442
            var maxResolution = null;
443
            // gmaps has no maxExtent at this point, need to check for null
444
            if(defaultBaseLayer.maxExtent != null){
445
                maxResolution = Math[(opts.displayOutsideMaxExtent ? 'max' : 'min')](
446
                        defaultBaseLayer.maxExtent.getWidth() / getWidth(),
447
                        defaultBaseLayer.maxExtent.getHeight() / getHeight()
448
                );
449
            }
450
            console.log("mapOptions.maxResolution: " + maxResolution);
451
            console.log("mapOptions.restrictedExtent: " + defaultBaseLayer.maxExtent);
452

  
453
            map = new OpenLayers.Map(
454
                    "openlayers_map",
455
                    {
456
                        // defines the map ui elements and interaction features
457
                        controls: defaultControls,
458

  
459
                        // maxResolution determines the lowest zoom level and thus places the map
460
                        // in its maximum extent into the available view port so that no additinal
461
                        // gutter is visible and no parts of the map are hidden
462
                        // see http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels
463
                        // IMPORTANT!!!
464
                        // the maxResulution set here will be overwritten if the baselayers maxResolution
465
                        // it is set
466
                        maxResolution: maxResolution,
467

  
468
                        // setting restrictedExtent the the maxExtent prevents from panning the
469
                        // map out of its bounds
470
                        restrictedExtent: defaultBaseLayer.maxExtent,
442
          var maxResolution = null;
443
          // gmaps has no maxExtent at this point, need to check for null
444
          if(defaultBaseLayer.maxExtent != null){
445
              maxResolution = Math[(opts.displayOutsideMaxExtent ? 'max' : 'min')](
446
                      defaultBaseLayer.maxExtent.getWidth() / getWidth(),
447
                      defaultBaseLayer.maxExtent.getHeight() / getHeight()
448
              );
449
          }
450
          console.log("mapOptions.maxResolution: " + maxResolution);
451
          console.log("mapOptions.restrictedExtent: " + defaultBaseLayer.maxExtent);
452

  
453
          map = new OpenLayers.Map(
454
            mapElement.attr('id'),
455
            {
456
              // defines the map ui elements and interaction features
457
              controls: defaultControls,
458

  
459
              // maxResolution determines the lowest zoom level and thus places the map
460
              // in its maximum extent into the available view port so that no additinal
461
              // gutter is visible and no parts of the map are hidden
462
              // see http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels
463
              // IMPORTANT!!!
464
              // the maxResulution set here will be overwritten if the baselayers maxResolution
465
              // it is set
466
              maxResolution: maxResolution,
467

  
468
              // setting restrictedExtent the the maxExtent prevents from panning the
469
              // map out of its bounds
470
              restrictedExtent: defaultBaseLayer.maxExtent,
471 471
//                      maxExtent: defaultBaseLayer.maxExtent,
472 472

  
473
                        // Setting the map.fractionalZoom property to true allows zooming to an arbitrary level
474
                        // (between the min and max resolutions).
475
                        // fractional tiles are not supported by XYZ layers like OSM so this option would
476
                        // break the tile retrieval for OSM (e.g.: tile for fractional zoom level
477
                        // 1.2933333333333332 = http://b.tile.openstreetmap.org/1.2933333333333332/1/0.png)
478
                        fractionalZoom: defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.OSM" && defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.XYZ",
473
              // Setting the map.fractionalZoom property to true allows zooming to an arbitrary level
474
              // (between the min and max resolutions).
475
              // fractional tiles are not supported by XYZ layers like OSM so this option would
476
              // break the tile retrieval for OSM (e.g.: tile for fractional zoom level
477
              // 1.2933333333333332 = http://b.tile.openstreetmap.org/1.2933333333333332/1/0.png)
478
              fractionalZoom: defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.OSM" && defaultBaseLayer.CLASS_NAME != "OpenLayers.Layer.XYZ",
479 479

  
480
                        eventListeners: opts.eventListeners,
481
                        // creating the map with a null theme, since we include the stylesheet directly in the page
482
                        theme: null
480
              eventListeners: opts.eventListeners,
481
              // creating the map with a null theme, since we include the stylesheet directly in the page
482
              theme: null
483 483

  
484
                    }
485
            );
484
            }
485
          );
486 486

  
487
            //add the base layers
487
          //add the base layers
488 488

  
489
            addLayers(baseLayers);
490
            map.setBaseLayer(defaultBaseLayer);
489
          addLayers(baseLayers);
490
          map.setBaseLayer(defaultBaseLayer);
491 491

  
492
            // calculate the bounds to zoom to
493
            zoomToBounds = zoomToBoundsFor(opts.boundingBox ? opts.boundingBox : defaultBaseLayerBoundingBox, defaultBaseLayer);
494
            zoomToBounds = cropBoundsToAspectRatio(zoomToBounds, map.getSize().w / map.getSize().h);
495
            console.log("baselayer zoomToBounds: " + zoomToBounds);
492
          // calculate the bounds to zoom to
493
          zoomToBounds = zoomToBoundsFor(opts.boundingBox ? opts.boundingBox : defaultBaseLayerBoundingBox, defaultBaseLayer);
494
          zoomToBounds = cropBoundsToAspectRatio(zoomToBounds, map.getSize().w / map.getSize().h);
495
          console.log("baselayer zoomToBounds: " + zoomToBounds);
496 496

  
497 497
        };
498 498

  

Also available in: Unified diff