[OpenLayers-Users] Converting the output
of getLonLatFromViewPortPx to spherical coordinates
Christopher Schmidt
crschmidt at metacarta.com
Wed Oct 7 11:20:50 EDT 2009
On Wed, Oct 07, 2009 at 10:33:45AM -0400, J. Brian Adams wrote:
> Thanks Andrea, but sadly I had already tried that to no avail.
>
> The problem seems to be that mapnik (using epsg 4326) is UTM and
> locations are measured in meters from (0, 0) while I need the actual
> spherical coordinates in degrees.
You're confusing terms a lot here.
Most likely, what you're actually trying to say is that:
"My mapnik tiles" (based on OSM, I assume?) "are projected in the standard
'spherical mercator' projection, where units are meters from 0,0.
I am interested in getting the coordinates in decimal degrees,
commonly referred to as EPSG:4326."
> I could work on a function to do the conversion, but before I do I
> wanted to know if this was something that already exists.
Get the result (a lonlat).
Transform the result:
lonlat.transform(new OpenLayers.Projection("EPSG:900913"),
new OpenLayers.Projection("EPSG:4326"));
Andreas's comments were about how you could change things like the
MousePosition control, which displays these values.
getLonLatFromPixel will always use the Map's projection.
-- Chris
> Thanks again,
>
> Brian
>
>
> On Oct 7, 2009, at 3:41 AM, Andreas Hocevar wrote:
>
> > J. Brian Adams wrote:
> >> I have been trying to mimic the Click Event Example in which a single
> >> mouse click triggers an alert box showing the location of the click
> >> in
> >> spherical coordinates (degrees North and Ease.) In my code when I
> >> click on a location the alert box shows the coordinates not as
> >> degrees
> >> (ie. 40 N -76.2 E) but instead as location (4865946 N, -8482597 E)
> >>
> >> Since I need to access the data in spherical coordinates, how might I
> >> transform the result from what I assume is the epsg4326 projection
> >> coordinates to degrees?
> >>
> >
> > Just configure EPSG:4326 as displayProjection of your map, so it looks
> > like this:
> >
> > var map = new OpenLayers.Map("map", {
> > displayProjection: new OpenLayers.Projection("EPSG:4326")
> > });
> >
> > Regards,
> > Andreas.
> >
> >
> >
> > --
> > 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
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list