我在谷歌地图应用程序中的下面,并希望显示高度转换为英尺,但我怎么向上/向下舍入到最近的数字? (消除十进制数字后)我尝试了number.toFixed(x)
方法,但似乎没有做到这一点。舍入数字javascript - 数学
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);
}
});
}
谢谢你。结束于'Math.round(results [0] .elevation *(3.2808399))+“英尺”。)'' – RonnieT