[OpenLayers-Users] AW: [mapserver-users] Map projection not right in Openlayers

Arnd Wippermann arnd.wippermann at web.de
Wed Aug 24 20:19:39 EDT 2011


Hi,

You have to add the projection to the mapOptions. If the map is created
without this, then the projection is set by default to "EPSG:4326".

    mapOptions = {
        projection: new OpenLayers.Projection("EPSG:900913"),
        units: "m",
        numZoomLevels: 18,
        theme:'./theme/default/style.css',
        maxResolution: 156543.0339,
        maxExtent: new OpenLayers.Bounds(-20037508, -20037508,20037508,
20037508.34)
        //controls : []
    };
    map = new OpenLayers.Map('map', mapOptions);

Arnd

-----Ursprüngliche Nachricht-----
Von: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] Im Auftrag von jjwang
Gesendet: Donnerstag, 25. August 2011 01:24
An: mapserver-users at lists.osgeo.org
Betreff: [mapserver-users] Map projection not right in Openlayers

After I set the projection of the map as epsg:900913, on client-side,
Openlayers still tells me that the projection of this layer is  "EPSG:4326".
map file:
MAP
  PROJECTION
	"init=epsg:900913"
  END
  ........
  ........
  
  WEB
    TEMPLATE global.html
    IMAGEPATH "/ms4w/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
    
    METADATA
      "wms_title" "My Global Map WMS Server"
      "wms_srs" "EPSG:900913"
      "ows_enable_request"   "*"
    END
  END
  
  LAYER
    PROJECTION
    "init=epsg:4326"
    END
    ......
    ......
  END

  ......
  ......
END

Js code:
var propertydata_layer = new OpenLayers.Layer.WMS(
        'Property Data',
       
'http://localhost:9999/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/global.
map&',
        {layers: 'nsw', transparent:true},
        {opacity: .5}
);
this.map.addLayers([propertydata_layer]);

Result: map.layers[5]
div: HTMLDivElement
events: Class
grid: Array[3]
id: "OpenLayers.Layer.WMS_77"
inRange: true
isBaseLayer: false
map: Class
maxExtent: Class
maxResolution: 0.1
maxScale: 480.6248291015625
minResolution: 0.00000152587890625
minScale: 31498228.8
name: "Property Data"
numLoadingTiles: 0
numZoomLevels: 17
opacity: 0.5
options: Object
origin: Class
params: Object
projection: "EPSG:4326"
resolutions: Array[17]
scales: Array[17]
tileSize: Class
units: "degrees"
url:
"http://localhost:9999/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/global.
map&"
__proto__: Object

Is this a Mapserver issue or Openlayers?

JJ

--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Map-projection-not-right-in-Openlayer
s-tp6722667p6722667.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the Users mailing list