Project

General

Profile

« Previous | Next » 

Revision 74b1edb3

Added by Andreas Kohlbecker almost 5 years ago

ref #8347 fixing wrong projection transformation for data maps - improved version

View differences:

modules/cdm_dataportal/js/map/openlayers_map.js
33 33
    boundingBox: null,
34 34
    aspectRatio: 2, // w/h
35 35
    showLayerSwitcher: false,
36
    baseLayerNames: ["mapproxy_vmap0"],
37
    defaultBaseLayerName: 'mapproxy_vmap0',
36
    baseLayerNames: ["open_topomap"],
37
    defaultBaseLayerName: 'open_topomap',
38 38
    maxZoom: 15,
39 39
    minZoom: 0,
40 40
    debug: true,
......
396 396
       */
397 397
      var referenceProjection = function() {
398 398
        if(defaultBaseLayer){
399
          return defaultBaseLayer.projection;
399
          if(defaultBaseLayer.projection){
400
            return defaultBaseLayer.projection;
401
          } else if(defaultBaseLayer.sphericalMercator === true){
402
            return CdmOpenLayers.projections.epsg_900913;
403
          } else {
404
            log("Error - referenceProjection() defaultBaseLayer " + defaultBaseLayer.name + " misses projection information");
405
          }
406

  
400 407
        } else {
401 408
          log("Error - referenceProjection() defaultBaseLayer not set");
402 409
          return null;
......
645 652
            if(layers.length > 0) {
646 653
              // calculate zoomBounds using the first layer
647 654
              if(mapResponseObj.bbox !== undefined){
648
                // mapResponseObj.bbox are bounds for the projection of the specific layer
655
                // mapResponseObj.bbox are bounds  are always returned in EPSG:4326 since the point service does not know about the projection
649 656
                var newBounds =  OpenLayers.Bounds.fromString( mapResponseObj.bbox );
650
                //newBounds.transform(layers[0].projection, map.getProjectionObject());
651
                newBounds.transform(CdmOpenLayers.projections.epsg_4326, referenceProjection());
657
                if(dataType === "POINT"){
658
                  console.log("createDataLayer() : transforming newBounds: " + newBounds + " to referenceProjection()=" + referenceProjection() + "(map.getProjectionObject()=" + map.getProjectionObject() +")" );
659
                  // newBounds.transform(layers[0].projection, map.getProjectionObject());
660
                  newBounds.transform(CdmOpenLayers.projections.epsg_4326, referenceProjection());
661
                } else {
662
                  // Type == AREA
663
                  console.log("createDataLayer() : no need to transform the newBounds: " + newBounds + " to referenceProjection()=" + referenceProjection());
664
                  // expecting that the bounds are already in the correct projection.
665
                }
666

  
652 667
                if(dataBounds !== null){
653 668
                  dataBounds.extend(newBounds);
654 669
                } else if(newBounds !== undefined){

Also available in: Unified diff