[OpenLayers-Users] How to change the display coordinates

Ivan Grcic igrcic at gmail.com
Sun Sep 6 05:01:14 EDT 2009


Hi all,

you could also check this
http://openlayers.org/pipermail/dev/2009-February/004389.html

Theirs function is a bit more advanced, as it takes correct decimal rounding
into account,

hope it helps,

cheers

On Fri, Sep 4, 2009 at 8:48 PM, fsalas <fsalas at geocuba.cu> wrote:

> Andreas , I test your solutions but openlayer
>
> show the standard coordinates format ej. -79.456,21.2365
>
> Why, the formatOutput don't affect ?
>
> ..
> .
> .
>
> map.addControl(mp);
>
> Regards,
> salas.
>
>
> ----- Original Message -----
> From: "Andreas Hocevar" <ahocevar at opengeo.org>
> To: "users" <users at openlayers.org>
> Sent: Friday, September 04, 2009 9:13 AM
> Subject: Re: [OpenLayers-Users] How to change the display coordinates
>
>
> Please provide a valid email address, and post follow-up questions to
> the list.
>
> You want me to show you how to calculate minutes and seconds?
>
> Here are two functions from Mapbuilder  [1]:
>
>  /**
>   * Decimal to DMS conversion
>   */
>  convertDMS = function(coordinate, type) {
>    var coords = new Array();
>
>    abscoordinate = Math.abs(coordinate)
>    coordinatedegrees = Math.floor(abscoordinate);
>
>    coordinateminutes = (abscoordinate - coordinatedegrees)/(1/60);
>    tempcoordinateminutes = coordinateminutes;
>    coordinateminutes = Math.floor(coordinateminutes);
>    coordinateseconds = (tempcoordinateminutes - coordinateminutes)/(1/60);
>    coordinateseconds =  Math.round(coordinateseconds*10);
>    coordinateseconds /= 10;
>
>    if( coordinatedegrees < 10 )
>      coordinatedegrees = "0" + coordinatedegrees;
>
>    if( coordinateminutes < 10 )
>      coordinateminutes = "0" + coordinateminutes;
>
>    if( coordinateseconds < 10 )
>      coordinateseconds = "0" + coordinateseconds;
>
>    coords[0] = coordinatedegrees;
>    coords[1] = coordinateminutes;
>    coords[2] = coordinateseconds;
>    coords[3] = this.getHemi(coordinate, type);
>
>    return coords;
>  }
>
>  /**
>   * Return the hemisphere abbreviation for this coordinate.
>   */
>  getHemi = function(coordinate, type) {
>    var coordinatehemi = "";
>    if (type == 'LAT') {
>      if (coordinate >= 0) {
>        coordinatehemi = "N";
>      }
>      else {
>        coordinatehemi = "S";
>      }
>    }
>    else if (type == 'LON') {
>      if (coordinate >= 0) {
>        coordinatehemi = "E";
>      } else {
>        coordinatehemi = "W";
>      }
>    }
>
>    return coordinatehemi;
>  }
>
> Now this is what you could do:
>
> var mp = new OpenLayers.Control.MousePosition({
>   formatOutput: function(lonLat) {
>       var markup = convertDMS(lonLat.lat, "LAT");
>       markup += " " + convertDMS(lonLat.lon, "LON");
>       return markup
>   }
> });
>
> Regards,
> Andreas.
>
> [1]
>
> http://svn.codehaus.org/mapbuilder/trunk/mapbuilder/lib/widget/CursorTrack.js
>
> fsalas wrote:
> > Thanks Andreas for your cooperations,
> >
> > but I have one doubt about How I use your function
> >
> > Is this possible send me one example about?
> >
> > Best Regards
> >
> > Salas
> >
> > ----- Original Message ----- From: "Andreas Hocevar"
> > <ahocevar at opengeo.org>
> > To: "fsalas" <fsalas at geocuba.cu>
> > Cc: <users at openlayers.org>
> > Sent: Friday, September 04, 2009 3:38 AM
> > Subject: Re: [OpenLayers-Users] How to change the display coordinates
> >
> >
> >> fsalas wrote:
> >>> Hi , I need to change the display coordinates in degree minutes and
> >>> second format example (NE 50 20´ 23´´ )
> >>
> >> Just configure your MousePosition control with a custom formatOutput
> >> function:
> >>
> >> var mp = new OpenLayers.Control.MousePosition({
> >>    formatOutput: function(lonLat) {
> >>        var markup = "<your output markup here>";
> >>        return markup
> >>    }
> >> });
> >>
> >> Regards,
> >> Andreas.
> >>
> >> --
> >> Andreas Hocevar
> >> OpenGeo - http://opengeo.org/
> >> Expert service straight from the developers.
> >>
> >>
> >
> >
> > ___________________________________
> > Dirección de Comunicaciones
> > Grupo Empresarial GEOCUBA
> > Este mensaje esta libre de virus. Revisado por Kaspersky Antivirus
> > ----------------------------------------------------------------------
> > Definition count:  2495798
> > Definition date:  9/4/2009
> > SecurityPlus version: 3.0.5
> >
> >
> >
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
> ___________________________________
> Dirección de Comunicaciones
> Grupo Empresarial GEOCUBA
> Este mensaje esta libre de virus.
> Revisado por Kaspersky Antivirus
> ----------------------------------------------------------------------
> Definition count:  2495798
> Definition date:  9/4/2009
> SecurityPlus version: 3.0.5
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Ivan Grcic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090906/b6d67527/attachment.html


More information about the Users mailing list