For example if coordinates are 17.12345678, -82.12345678
, and I want to convert them to 3 decimal digits.
Expected result: 17.123, -82.123
Is there any API in OpenLayers 2 to truncate coordinates (LonLat) to decimal precision?
For example if coordinates are 17.12345678, -82.12345678
, and I want to convert them to 3 decimal digits.
Expected result: 17.123, -82.123
Is there any API in OpenLayers 2 to truncate coordinates (LonLat) to decimal precision?
If you are referring to the LonLat object you could define your own method
OpenLayers.LonLat.prototype.truncate = function(digits) {
var pow = Math.pow(10, digits);
return new OpenLayers.LonLat(Math.round(this.lon * pow)/pow, Math.round(this.lat * pow)/pow);
}