[OpenLayers-Users] Display Coordinates
Riggi Valerio
vash.84 at virgilio.it
Fri Nov 23 06:32:03 PST 2012
I was missing an "else if" on my code and the mercator was always setted
to EPSG:900913, now it seems to work but the wgs-84 version dosen't
center the map on the desired position:
center:newOpenLayers.LonLat(15.4386126995087,38.2423138618469).transform(geographic,mercator)
why?
Many thanks
Valerio
Il 22/11/2012 22:08, Phil Scadden ha scritto:
> Okay, you have added displayProjection.
> So looking at the formatOutput function, I see.
> lonLat now comes into the function as lat/lon in 4326.
> you convert to mercator
> However lonLat.transform changes lonLat.
>
> try
> var geoCoor = lonLat.clone();
> geoCoor.transform(geographic, mercator);
> var lat = lonLat.lat;
> var long = lonLat.lon;
> var ns = OpenLayers.Util.getFormattedLonLat(lat);
> var ew = OpenLayers.Util.getFormattedLonLat(long,'lon');
> return '<div style=\"color: green; font-size: 14px; font-weight: bold;
> background-color: white; width: 700px; text-align: left;\">Coordinate: '
> + ns + ', ' + ew + ' (' + (Math.round(geoCoor.lat * 10000) / 10000) + ',
> ' + (Math.round(geoCoor.lon * 10000) / 10000) + ')' + '</div>';
> }
>
> Get used to using firebug or similar. It makes it easy to see what is
> going on. Put breakpoint in formatOutput and then watch the values.
>
>
> Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121123/2e4c4b68/attachment-0001.html>
More information about the Users
mailing list