Reputation: 15
Im using openlayers map where the i have few points in map and on clicking each it show its Northing, Easting values in a pop-up
When the user changes unit system from Metric to Imperial we observe the scale line unit changes in map. Similarly i need the Northing , Easting values of a point displayed to change based on unit (Metric - meter, Imperial - foot). below is the sample unit conversion
Eg: In metric (meter)
North - 26.27
East - 20
In Imperial (feet)
North - 86.20
East - 65.62
I expect the same conversion to happen inside map when unit change is done. I can receive the unit system changed inside map. But how to handle the unit conversion dynamically in map
Upvotes: 0
Views: 212
Reputation: 17962
The scaleline control isn't linked to your popup which presumably use projection units?
You would need to change the code for your popups, for example
var x = coord[0];
var y = coord[1];
if (scaleline.getUnits() == 'imperial') {
x = x * 100 / (2.54 * 12);
y = y * 100 / (2.54 * 12);
}
content.innerHTML = 'North - ' + y.toFixed(2) + '<br>East - ' + y.toFixed(2);
Upvotes: 1