Googleマップアプリケーションでは以下のようになり、標高をフィートに変換して表示したいのですが、最も近い数値に丸めたり下げたりするにはどうすればいいですか? (小数点以下を切り捨てて)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