0
함수에서 고도 값을 가져 오는 데 몇 가지 문제가 있습니다. 나는 그 가치를 얻을 수 없다. 누군가가 그 해결책을 가지고 있다면 좋을 것입니다.
다음 내 코드입니다 :고도 요청 값을 되 찾는 방법
function getElevation(latLng) {
seaLevel = 'Error';
var locations = [];
locations.push(latLng);
//Create a LocationElevationRequest object using the array[0] value
var positionalRequest = {
'locations': locations
}
//Initiate the location request
elevationService.getElevationForLocations(positionalRequest, function(results, status) {
if (status == google.maps.ElevationStatus.OK) {
// Retrieve the first result
if (results[0]) {
var seaLvl = parseFloat(results[0].elevation.toFixed(1));
}
dropElevation(seaLvl);
}
document.getElementById("response").innerHTML = seaLevel;
});
function dropElevation(tmpLevel) {
//alert(tmpLevel); at this point the value is correct
seaLevel = tmpLevel;
}
return seaLevel; //at this point the value is always as defined above
} //End function (getElevation)
그것의 호출은 다음과 같습니다 : 내가 잘못
귀도
답장을 보내 주셔서 감사합니다 ... –