[OpenLayers-Dev] Translate mousecoordinates and show them on page

LightningStrike fredrik.andersson.79 at gmail.com
Thu Jul 21 07:55:24 EDT 2011


I'm trying to transform mouse coordinates but it doesn't work, i want to show
the coordinates in four different ways. "LonLat", "SWEREF99TM", "SWEREF99 13
30" and in "RT90"
The code is something like this

the map is in "EPSG:3008" so i'm not shore which format
map.getLonLatFromViewPortPx(e.xy) gets, is it the maps projection or LonLat?
<----------------START--------------->
var mousepos = map.getLonLatFromViewPortPx(e.xy);
			
var sweref = mousepos.transform(new OpenLayers.Projection("EPSG:3006"),new
OpenLayers.Projection("EPSG:3008"));
var lonlat  =  mousepos.transform(new OpenLayers.Projection("EPSG:3006"),new
OpenLayers.Projection("EPSG:4326"));
var rt90  =  mousepos.transform(new OpenLayers.Projection("EPSG:3006"),new
OpenLayers.Projection("EPSG:3021"));
			
OpenLayers.Util.getElement("coords1").innerHTML = "*Halmstads lokala
(SWEREF99 13 30):* <br/>" + mousepos;
OpenLayers.Util.getElement("coords2").innerHTML = "*Long/Lat:* <br/>" +
lonlat; 
OpenLayers.Util.getElement("coords3").innerHTML = "*SWEREF99 TM:* <br/>" +
sweref; 
OpenLayers.Util.getElement("coords4").innerHTML = "*RT90 2.5 gon V:* <br/>"
+ rt90;
<-----------------------END----------------------->

The output shows the same coordinates as the map uses on all four so the
transformations doesn't work

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Translate-mousecoordinates-and-show-them-on-page-tp6606425p6606425.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.


More information about the Dev mailing list