helper.js Example File
mapviewer/helper.js
.pragma library
function roundNumber(number, digits)
{
var multiple = Math.pow(10, digits);
return Math.round(number * multiple) / multiple;
}
function formatTime(sec)
{
var value = sec
var seconds = value % 60
value /= 60
value = (value > 1) ? Math.round(value) : 0
var minutes = value % 60
value /= 60
value = (value > 1) ? Math.round(value) : 0
var hours = value
if (hours > 0) value = hours + "h:"+ minutes + "m"
else value = minutes + "min"
return value
}
function formatDistance(meters)
{
var dist = Math.round(meters)
if (dist > 1000 ){
if (dist > 100000){
dist = Math.round(dist / 1000)
}
else{
dist = Math.round(dist / 100)
dist = dist / 10
}
dist = dist + " km"
}
else{
dist = dist + " m"
}
return dist
}