使用Google Earth / Map API获取精确(1km特定)系列的海拔高度值

时间:2012-07-01 09:46:26

标签: javascript google-maps kml google-earth

使用Google地球(或地图)API,我可以使用哪些函数来获取特定区域的高度图/高度(精度为千米而不是纵向精度)? < / p>

例如,如果我的位置Lat = 11 Long = 12,我可以获得该位置的海拔高度吗?我知道谷歌的高度可能不准确,并且精度不会达到5米甚至可能达到1公里精度但是没关系(这对于简单有趣的谷歌地球应用程序而言不需要高度精确度)。

下面的代码可以获取鼠标当前所在位置的当前高度,但是是否有函数调用来获取给定位置的系列高度值

google.earth.addEventListener(ge.getWindow(), 'mousemove', function(evt) {

   if (event.getDidHitGlobe()) {
     var lat  = event.getLatitude();
     var long = event.getLongitude();
     var groundAltitude = ge.getGlobe().getGroundAltitude(latitude, longitude);
     if (groundAltitude) {
        alert(groundAltitude.toFixed(2));
   }
});

这是唯一的方法吗?请注意,这对于1经度/纬度是精确的,我可以得到更精确(如1km特定)

function obtainAreaAlt(startLong, endLong, startLat, endLat) {

     var alt = {};
     while (startLong < endLong) {
         var origLat = startLat;
         while (startLat < endLat) {
           var a = ge.getGlobe().getGroundAltitude(startLat, startLong);
           if (a)
              alt[""+startLat+","+startLong] = a.toFixed(2);
           startLat++;
         }
         startLong++;
         startLat = origLat;
     }

     return alt;
}

2 个答案:

答案 0 :(得分:2)

您可以使用Google Maps API的Elevation Service。它接受一系列位置,(纬度/经度值)或路径。

在这里演示:

https://google-developers.appspot.com/maps/documentation/javascript/examples/elevation-paths

此处的文档:

https://developers.google.com/maps/documentation/javascript/reference#ElevationService

请注意,有使用限制!

答案 1 :(得分:0)

使用google earth插件,您需要移动到该位置,如果您正在选择高程并等待高程数据元素完成下载到浏览器以获得更好的高程分辨率。

确定高程数据是否已完成下载使用ge.getStreamingPercent()

http://earth-api-samples.googlecode.com/svn/trunk/examples/streamingpercent.html

如果缩小太远,地球地球上会填充低分辨率地形模型