點位高程資訊

<< Click to Display Table of Contents >>

Navigation:  3D API 說明範例 > 功能 > 高程資訊 >

點位高程資訊

 

 

檢視範例

範例下載

 

 

<說明>

在本範例中,我們將示範如何展示點位高程資訊,說明如下:

 

 

<範例>

   var earth_ = null;

         function documentLoad()

       {

             SuperGIS.Initialize("/ServerGate/", function () {

                 SuperGIS.ServerEarth.Initialize(InitEarth);

             });

         }

 

     function InitEarth()

     {

         var pBody = new SuperGIS.Windows.HTMLContainer(document.getElementById("example"));

 

         var sHost = location.href;

         var idx = sHost.indexOf("/", 8);

         if (idx >= 0) sHost = sHost.substring(0, idx);

         CreateHTML5Earth(pBody, function (pEarth) { EarthLoaded(pEarth); });

 

         function EarthLoaded(pEarth)

         {

             earth_ = pEarth;

             pEarth.Scene.BackgroundColor = pEarth.CreateColor(0, 0, 0, 1);

             pEarth.SetupSystem(true, s_WGS84);

             pEarth.SetupSkin(pEarth.CreateEnvelope(-180, 180, -90, 90, s_WGS84), "");

             pEarth.MajorGraticule.Visible = false;

             pEarth.MinorGraticule.Visible = false;

 

             Dtm = new SuperGIS.DTMLayer("http://203.66.168.227/TGOS3D_WMTS/World/SimpleWMTS_GLOBE_W_D.aspx?apikey=mcXodoZFWJaUJRFS5H3gCec83a570/QupBX5ROqlSmu9vZW61YOYMe86Om9zQ2g2pVSGtjfLi5gex++mKHMFNK95UFUwZD3TtpSdH73WhL5KMv0WZVPMe5rB4KiLpaRrReusEFx+W10=&appid=BHvpiOJ5Wp41CsxemFMNWQ==",

                                               pEarth, { layer: 'Map' }, null);

 

             // 指定圖磚服務的 WMTS 網址, 欲加入的圖層名稱, dtm layer 及 callback function 名稱

             //Tile = new SuperGIS.TileLayer(getDataServicePath() + 'TC_fly/SimpleWMTS.aspx',

               //                                pEarth, { layer: 'TC' }, Dtm, null);

             Tile = new SuperGIS.TileLayer("http://203.66.168.227/TGOS3D_WMTS/World/SimpleWMTS_GLOBE_W.aspx?apikey=mcXodoZFWJaUJRFS5H3gCec83a570/QupBX5ROqlSmu9vZW61YOYMe86Om9zQ2g2pVSGtjfLi5gex++mKHMFNK95UFUwZD3TtpSdH73WhL5KMv0WZVPMe5rB4KiLpaRrReusEFx+W10=&appid=BHvpiOJ5Wp41CsxemFMNWQ==",

                                               pEarth, { layer: 'Map' }, Dtm, null);

 

             pEarth.SetViewpoint(120.789, 24.160, 3000, 0, 50, true);

 

             pEarth.addEventListener("mousedown", QueryElevation, false); // 滑鼠鍵按下時觸發

             pEarth.addEventListener("mousemove", MouseMove, false);

 

             var pCam = pEarth.GetCamera();

             pCam.addEventListener("changed", CameraChanged, false); // Camera 狀態改變時觸發

         }

 

         var pInfoWindow = null;

         function QueryElevation(tEvent) {

             var pScene = earth_.GetScene();

             var pCamera = earth_.GetCamera();

             var pGlobe = earth_.GetGlobe();

 

             var CurPosition = pScene.PositionFromDevice(new SuperGIS.DDDCore.Vector3(tEvent.x, tEvent.y, 0));

             var pPick = earth_.Objects.Picking(SuperGIS.DDDCore.RenderPriority.Unknown, pCamera.EyeAt, pCamera.Ray(CurPosition), 0);

             if (pPick == null)

                 return;

 

             var rloc = pPick.GetLocate();

             var globeLoc = pGlobe.GeodeticFromCartesian(rloc);

             var elevation = globeLoc.Altitude;

 

             if (pInfoWindow != null) {

                 pInfoWindow.close();

                 pInfoWindow = null;

             }

 

             var infoStr = '<table border="1">';

             infoStr += "<tr><td>";

             infoStr += "高程";

             infoStr += "</td><td>";

             infoStr += parseFloat(elevation).toFixed(1) + "公尺";

             infoStr += "</td></tr>";

             infoStr += '</table>';

 

             pInfoWindow = new SuperGIS.InfoWindow(infoStr, globeLoc, { maxWidth: 250, pixelOffsetX: 100, pixelOffsetY: 0 }); // 建立屬性視窗

             pInfoWindow.open(earth_, document.getElementById("example"));

         }

 

         function CameraChanged(tEvent) {

             // Camera 狀態改變就關掉視窗

             if (pInfoWindow != null) {

                 pInfoWindow.close();

                 pInfoWindow = null;

             }

         }

 

         function MouseMove(tEvent) {

             var pScene = earth_.GetScene();

             var pG = pScene.GetGraphics(2);

            pG.drawText("以滑鼠右鍵進行地面點選展示高程", 20, 20, "black", "white", "18", "Consolas");

         }

       }

 

 

 

 

 


© 2017 Supergeo Technologies Inc.