<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Yes, this is the difficult solution. It works, but I was thinking in
another direction. As Bart pointed out, it is possible to put
multiple Mouseposition controls with different DisplayProjections on
a page by means css classes. This means that I can influence the
position of these controls and their projected coordinate values
without any other formating. However, I would also like to be able
to change to format of a lon-lat value to degrees-minutes-seconds.
Is there a way to get at the numeric value of a MousePosition
control and alter it?<br>
<br>
There are other possibilities for this. Older maps often have
national central meridians, like Paris, Amsterdam, Djakarta. To see
the lon-values on those map in Greenwich values, all lon values need
to be added with a constant. It would be nice if that could be done
automatically via the MousePointer control.<br>
<br>
Jan <br>
<br>
On 1/10/2013 2:46 PM, Richard Greenwood wrote:
<blockquote
cite="mid:CAHBySPY9kZTjfii4LzORQyQJcZF-RUw0J11OikUOP1VmiArwiQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Thu, Jan 10, 2013 at 6:02 AM, Jan
Hartmann <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:j.l.h.hartmann@uva.nl" target="_blank">j.l.h.hartmann@uva.nl</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"> Hi Rich, how did
you get the lon-lat values on your map formattted as
degrees/minutes/seconds (next to the default decimal
degrees?)<br clear="all">
</div>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">Hey Jan -<br>
<br>
</div>
<div class="gmail_extra">The hardest part was getting the
coordinates to be the same width so that they did not cause
other page elements to move. Without that the display was
quite "jittery". My code is below. I'm using my original CSCS
transformation library, not proj4js, but that shouldn't
matter.<br>
<br>
</div>
<div class="gmail_extra">Best regards,<br>
Rich<br>
<br>
rwg.cursorCoords = function(e) {<br>
<br>
var position = this.events.getMousePosition(e);<br>
var pointXY = this.getLonLatFromPixel(position); /* this has
a transform method */<br>
var p = new <a moz-do-not-send="true" href="http://CSCS.PT">CSCS.PT</a>(pointXY.lon,
pointXY.lat);<br>
var text;<br>
<br>
/* *** Private functions ***************** */<br>
var zeroPad2 = function(num) {<br>
num += '';<br>
return (num.length<2) ? "0"+num : num;<br>
};<br>
<br>
var zeroPad4 = function(num) {<br>
num += '';<br>
return (num.length<4) ? "0"+num : num;<br>
};<br>
<br>
var dd2dms = function(v) {<br>
var fv = v % 1; // fractional part<br>
var d = v - fv; // integer part (degrees)<br>
fv = Math.abs(fv);<br>
var m = fv * 60; // minutes<br>
var mf = m % 1; // fractional part of minutes<br>
var mi = m - mf; // integer part of minutes<br>
var s = Math.round(mf*600)/10; // seconds<br>
s = s.toFixed(1);<br>
return d + "° " + zeroPad2(mi) +
"' "+ zeroPad4(s) + """;<br>
};<br>
<br>
// display original state plane coords<br>
text = "N: " + Math.round(p.y) + " E: " + Math.round(p.x);<br>
OpenLayers.Util.getElement("coords").innerHTML = text;<br>
<br>
// convert to long/lat and display<br>
CSCS.transform(csSP, csLL, p);<br>
<br>
text = "<table cellpadding=\"0\"
cellspacing=\"0\"><tr><td>";<br>
text += "Long: " + dd2dms(p.x) +
"</td><td> Lat: " + dd2dms(p.y);<br>
text +=
"</td></tr><tr><td>Long: " +
Math.round(p.x*10000)/10000 +
"°</td><td> Lat: " +
Math.round(p.y*10000)/10000;<br>
text += "°</td></tr></table>";<br>
<br>
OpenLayers.Util.getElement("coordsLL").innerHTML = text;<br>
<br>
// convert long/lat to UTM and display<br>
CSCS.transform(csLL, csUTM, p);<br>
text = "X =" + Math.round(p.x) + " Y = " + Math.round(p.y);<br>
OpenLayers.Util.getElement("coordsUTM").innerHTML = text;<br>
<br>
};<br>
<br>
</div>
<div class="gmail_extra"><br>
<br>
<br>
<br>
-- <br>
Richard Greenwood<br>
<a moz-do-not-send="true"
href="mailto:richard.greenwood@gmail.com">richard.greenwood@gmail.com</a><br>
<a moz-do-not-send="true" href="http://www.greenwoodmap.com">www.greenwoodmap.com</a>
</div>
</div>
</blockquote>
</body>
</html>