У меня есть ниже в приложении Google Map и хочу отобразить высоту, преобразованную в футы, но как мне округлить вверх / вниз до ближайшего числа?(исключить цифры после десятичной дроби) Я попробовал метод number.toFixed(x)
, но, похоже, ничто не помогло.
function getElevation(event) {
var locations = [];
var clickedLocation = event.latLng;
locations.push(clickedLocation);
var positionalRequest = { 'locations': locations }
// Initiate the location request
elevator.getElevationForLocations(positionalRequest, function(results, status) {
if (status == google.maps.ElevationStatus.OK) {
// Retrieve the first result
if (results[0]) {
// Open an info window indicating the elevation at the clicked position
infowindow.setContent("The elevation at this point <br/>is " + results[0].elevation*(3.2808399) + " feet.");
infowindow.setPosition(clickedLocation);
infowindow.open(map);
} else {
alert("No results found");
}
} else {
alert("Elevation service failed due to: " + status);
}
});
}