[OpenLayers-Users] Display Coordinates
Phil Scadden
p.scadden at gns.cri.nz
Thu Nov 22 13:08:37 PST 2012
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.
More information about the Users
mailing list