Hi all,<br><br>you could also check this <a href="http://openlayers.org/pipermail/dev/2009-February/004389.html">http://openlayers.org/pipermail/dev/2009-February/004389.html</a><br><br>Theirs function is a bit more advanced, as it takes correct decimal rounding into account,<br>
<br>hope it helps,<br><br>cheers<br><br><div class="gmail_quote">On Fri, Sep 4, 2009 at 8:48 PM, fsalas <span dir="ltr"><<a href="mailto:fsalas@geocuba.cu">fsalas@geocuba.cu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Andreas , I test your solutions but openlayer<br>
<br>
show the standard coordinates format ej. -79.456,21.2365<br>
<br>
Why, the formatOutput don't affect ?<br>
<br>
..<br>
.<br>
.<br>
<br>
map.addControl(mp);<br>
<br>
Regards,<br>
salas.<br>
<div class="im"><br>
<br>
----- Original Message -----<br>
From: "Andreas Hocevar" <<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>><br>
</div><div><div></div><div class="h5">To: "users" <<a href="mailto:users@openlayers.org">users@openlayers.org</a>><br>
Sent: Friday, September 04, 2009 9:13 AM<br>
Subject: Re: [OpenLayers-Users] How to change the display coordinates<br>
<br>
<br>
Please provide a valid email address, and post follow-up questions to<br>
the list.<br>
<br>
You want me to show you how to calculate minutes and seconds?<br>
<br>
Here are two functions from Mapbuilder [1]:<br>
<br>
/**<br>
* Decimal to DMS conversion<br>
*/<br>
convertDMS = function(coordinate, type) {<br>
var coords = new Array();<br>
<br>
abscoordinate = Math.abs(coordinate)<br>
coordinatedegrees = Math.floor(abscoordinate);<br>
<br>
coordinateminutes = (abscoordinate - coordinatedegrees)/(1/60);<br>
tempcoordinateminutes = coordinateminutes;<br>
coordinateminutes = Math.floor(coordinateminutes);<br>
coordinateseconds = (tempcoordinateminutes - coordinateminutes)/(1/60);<br>
coordinateseconds = Math.round(coordinateseconds*10);<br>
coordinateseconds /= 10;<br>
<br>
if( coordinatedegrees < 10 )<br>
coordinatedegrees = "0" + coordinatedegrees;<br>
<br>
if( coordinateminutes < 10 )<br>
coordinateminutes = "0" + coordinateminutes;<br>
<br>
if( coordinateseconds < 10 )<br>
coordinateseconds = "0" + coordinateseconds;<br>
<br>
coords[0] = coordinatedegrees;<br>
coords[1] = coordinateminutes;<br>
coords[2] = coordinateseconds;<br>
coords[3] = this.getHemi(coordinate, type);<br>
<br>
return coords;<br>
}<br>
<br>
/**<br>
* Return the hemisphere abbreviation for this coordinate.<br>
*/<br>
getHemi = function(coordinate, type) {<br>
var coordinatehemi = "";<br>
if (type == 'LAT') {<br>
if (coordinate >= 0) {<br>
coordinatehemi = "N";<br>
}<br>
else {<br>
coordinatehemi = "S";<br>
}<br>
}<br>
else if (type == 'LON') {<br>
if (coordinate >= 0) {<br>
coordinatehemi = "E";<br>
} else {<br>
coordinatehemi = "W";<br>
}<br>
}<br>
<br>
return coordinatehemi;<br>
}<br>
<br>
Now this is what you could do:<br>
<br>
var mp = new OpenLayers.Control.MousePosition({<br>
formatOutput: function(lonLat) {<br>
var markup = convertDMS(lonLat.lat, "LAT");<br>
markup += " " + convertDMS(lonLat.lon, "LON");<br>
return markup<br>
}<br>
});<br>
<br>
Regards,<br>
Andreas.<br>
<br>
[1]<br>
<a href="http://svn.codehaus.org/mapbuilder/trunk/mapbuilder/lib/widget/CursorTrack.js" target="_blank">http://svn.codehaus.org/mapbuilder/trunk/mapbuilder/lib/widget/CursorTrack.js</a><br>
<br>
fsalas wrote:<br>
> Thanks Andreas for your cooperations,<br>
><br>
> but I have one doubt about How I use your function<br>
><br>
> Is this possible send me one example about?<br>
><br>
> Best Regards<br>
><br>
> Salas<br>
><br>
> ----- Original Message ----- From: "Andreas Hocevar"<br>
> <<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>><br>
> To: "fsalas" <<a href="mailto:fsalas@geocuba.cu">fsalas@geocuba.cu</a>><br>
> Cc: <<a href="mailto:users@openlayers.org">users@openlayers.org</a>><br>
> Sent: Friday, September 04, 2009 3:38 AM<br>
> Subject: Re: [OpenLayers-Users] How to change the display coordinates<br>
><br>
><br>
>> fsalas wrote:<br>
>>> Hi , I need to change the display coordinates in degree minutes and<br>
>>> second format example (NE 50 20´ 23´´ )<br>
>><br>
>> Just configure your MousePosition control with a custom formatOutput<br>
>> function:<br>
>><br>
>> var mp = new OpenLayers.Control.MousePosition({<br>
>> formatOutput: function(lonLat) {<br>
>> var markup = "<your output markup here>";<br>
>> return markup<br>
>> }<br>
>> });<br>
>><br>
>> Regards,<br>
>> Andreas.<br>
>><br>
>> --<br>
>> Andreas Hocevar<br>
>> OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
>> Expert service straight from the developers.<br>
>><br>
>><br>
><br>
><br>
> ___________________________________<br>
> Dirección de Comunicaciones<br>
> Grupo Empresarial GEOCUBA<br>
> Este mensaje esta libre de virus. Revisado por Kaspersky Antivirus<br>
> ----------------------------------------------------------------------<br>
> Definition count: 2495798<br>
> Definition date: 9/4/2009<br>
> SecurityPlus version: 3.0.5<br>
><br>
><br>
><br>
<br>
<br>
--<br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<br>
<br>
___________________________________<br>
Dirección de Comunicaciones<br>
Grupo Empresarial GEOCUBA<br>
Este mensaje esta libre de virus.<br>
Revisado por Kaspersky Antivirus<br>
----------------------------------------------------------------------<br>
Definition count: 2495798<br>
Definition date: 9/4/2009<br>
SecurityPlus version: 3.0.5<br>
<br>
<br>
<br>
</div></div><div><div></div><div class="h5">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Ivan Grcic<br>