[OpenLayers-Users] MousePosition displayProjection problem ortho->epsg:4326

Heiko Schröter schroete at iup.physik.uni-bremen.de
Wed Apr 21 07:14:05 EDT 2010


Hello,

i have a problem with the MousePosition Control. The relevant code snippets are as follows: 


Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
Proj4js.defs["EPSG:0815"] = "+proj=ortho +lon_0=0 +lat_0=90";
Proj4js.defs["EPSG:0816"] = "+proj=ortho +lon_0=0 +lat_0=-90";

    var myoptions = {
	eventListeners: {
	    "changebaselayer": hd_mapBaseLayerChanged
	},
	units: "dd",
	maxResolution: 'auto',
	maxExtent: new OpenLayers.Bounds(-180,-90,180,90),
	controls: [
		   new OpenLayers.Control.PanZoom(),
		   new OpenLayers.Control.Navigation(),
		   new OpenLayers.Control.MousePosition({"numDigits": 2,
							 displayProjection: new OpenLayers.Projection("EPSG:4326")}),
		   new OpenLayers.Control.LayerSwitcher({"ascending": true}),
		   new OpenLayers.Control.Attribution()
		   ],

	numZoomLevels: 5
    };
    map = new OpenLayers.Map('map', myoptions);

The MousePosition works ok in EPSG:4326. Changing to 0815/0816 stalls the output of the MousePosition. Changing back to EPSG:4326 everything is ok again.
Omitting the "displayProjection" Option displays the MousePosition in meters in the 0815/0816 projection and in degrees in EPSG:4326 projection.

So what i want is to display the MousePosition in "degrees" in the 0815/0816 projection as in EPSG:4326.
As far as i understand the docs the transformation should be done automatically when proj4js is used.
What do i do wrong ?

Thanks and Regards
Heiko



More information about the Users mailing list