DMS display on MouseMove

william paul williampaul28 at YAHOO.COM
Thu Feb 9 05:57:25 PST 2006


I replay to the email, I didn't thing that the list will not receive the email!!!
   
  My problem isn't how you transform from DD to DMS. I already know this.
   
  I want to make the transformation in such manner that the DMS are displayed ON MOUSEMOVE over the map, which means that the coordinates are changing with position of the cursor on the map
   
  I did that for DD using a script found on the list, but I can't make it work for DMS
   
  My code looks like:
   
  var x2 = event.offsetX; // mouse coordinates in pixels
var y2 = event.offsetY; // mouse coordinates in pixels
  var res_dd = ([maxlon] - [minlon]) / [mapwidth]; // resolution in DD
var x_dd = [minlon]; 
var y_dd = [minlat];
  x1_dd = Math.round(((x2*res_dd) + x_dd)*1000000)/1000000; //coordinates in DD to be displayed on mousemove
y1_dd = Math.round(((([mapheight] - y2)*res_dd) + y_dd)*1000000)/1000000; //coordinates in DD to be displayed on mousemove
  
window.status="Latitude DD: " + y1_dd + " " + "Longitude DD: " + y1_dd;
   
  I tried for DMS:
   
  //for longitude in DMS
  
var dd = Math.floor(x1_dd);
var m = Math.floor((x1_dd - dd) * 60);
var s = Math.ceil((((x1_dd - dd) * 60) - m) *60);
   
  I also have tried to break the resolution in DMS, but I don't know how to multiply the resolution with the coordinates in pixel and then add to minlon
   
   
  I hope I was clear and thank you for the replay
   
  William
   
  william paul wrote:
> Hi:
>
> I know this, my problem is other, but...I will solve it

Please send all replies to the list as well. In the meantime, would
the following help --

//(0) Grab the dd value
var dd = obj.value;

// (1) The Degrees are simply the numbers to the left of the decimal
// (using 42.36824 as an example, the degrees would be 42)
var d = Math.floor(dd);

// (2) To determine the Minutes, multiply the number to the right of
// the decimal point by 60 (example: .36824 x 60 = 22.0944)
// (3) The Minutes are the numbers to the left of the decimal point
// (in this example, 22)
var m = Math.floor((dd - d) * 60);

// (4) To determine the Seconds, multiply the number to the right of
// the decimal point by 60 (example: .0944 x 60 = 5.664)
// (5) The Seconds are the numbers to the left of the decimal point,
// rounded up (in this example, 06)
var s = Math.ceil((((dd - d) * 60) - m) * 60);

// display it
var dms = d + ' deg, ' + m + ' min, ' + s + ' sec';

>
> */Puneet Kishor <punkish at EIDESIS.ORG>/* wrote:
>
>     william paul wrote:
>      > Hi:
>      >
>      > I display the coordinates on mousemove over the map. The
>     coordinates are
>      > in DD and UTM, but I would like display them also in DMS.
>      >
>
>      From the very first hit on Google --
>
>     (1) The Degrees are simply the numbers to the left of the decimal
>     (using 42.36824 as an example, the degrees would be 42)
>     (2) To determine the Minutes, multiply the number to the right of
>     the decimal point by 60 (example: .36824 x 60 = 22.0944)
>     (3) The Minutes are the numbers to the left of the decimal point
>     (in this example, 22)
>     (4) To determine the Seconds, multiply the number to the right of
>     the decimal point by 60 (example: .0944 x 60 = 5.664)
>     (5) The Seconds are the numbers to the left of the decimal point,
>     rounded up (in this example, 06)
>
>     Implementing it in Js is left as an exercise for the reader...
>
>


--
Puneet Kishor


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060209/645479f7/attachment.htm>


More information about the MapServer-users mailing list