不同比例尺切換

<< Click to Display Table of Contents >>

Navigation:  3D API 應用範例 >

不同比例尺切換

 

 

檢視範例

範例下載

 

 

<說明>

在本範例中,我們將示範如何在不同視角高度與比例,進行圖層的切換顯示,說明如下:

 

 

<範例>

         var earth_ = null;

       var VLayer1 = null;

       var VLayer2 = 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), sHost + "/ServerGate/Skin1.jpg");

             pEarth.MajorGraticule.Visible = false;

             pEarth.MinorGraticule.Visible = false;

 

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

             VLayer1 = new SuperGIS.VectorLayer(getDataServicePath() + 'project_block/SimpleWMTS.aspx',

                                               pEarth, { layer: '土地使用分區' }, LanduseFinish);

             VLayer2 = new SuperGIS.VectorLayer(getDataServicePath() + 'project_line/SimpleWMTS.aspx',

                                               pEarth, { layer: '管線' }, PipeFinish);

 

             //VLayer3 = new TGOS.TEVectorLayer('http://60.251.183.9/project_build/SimpleWMTS.aspx',

             //                                    tg3dEarth, { layer: '建物' }, BuildingLoadFinish);

             //VLayer3.setVisible(true);

 

             pEarth.SetViewpoint(120.656, 24.160, 500, 0, 50, true);

 

             var pCam = pEarth.GetCamera();

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

 

         }

 

         // 在 callback 中設定每個 feature 的符號樣式

         function LanduseFinish(array) {

             var rv = 128, gv = 255, bv = 128;

             for (var i = 0; i < array.length; i++) {

                 var mark = array[i];

                 var fc = earth_.CreateColor(rv / 255.0, gv / 255.0, bv / 255.0, 128 / 255.0);

                 mark.ReplaceZ = 0.5; // 設定高程 (公尺)

                 mark.DDDSymbol = earth_.CreateSimpleDDDFillSymbol(earth_.CreateModelMaterial(0, fc), null);

             }

         }

         function PipeFinish(array) {

             var rv = 128, gv = 255, bv = 128;

             for (var i = 0; i < array.length; i++) {

                 var mark = array[i];

                 var fc = earth_.CreateColor(rv / 255.0, gv / 255.0, bv / 255.0, 128 / 255.0);

                 mark.ReplaceZ = 0.5; // 設定高程 (公尺)

                 mark.DDDSymbol = earth_.CreateSimpleDDDLineSymbol(new SuperGIS.DDDCore.Material(earth_.CreateColor(1, 1, 0, 1.0), 0, 1));

             }

         }

 

         function CameraChanged(tEvent) {

             var pCam = earth_.GetCamera();

             var pos = pCam.Position; // Camera 的位置坐標為 Earth 的坐標系統 (X, Y, Z), Z 為高度 (公尺)

 

               // 於不同高度顯示不同的圖層

             VLayer1.setVisible(pos.Z >= 500);

             VLayer2.setVisible(pos.Z < 500);

         }

     }

 

 

 


© 2017 Supergeo Technologies Inc.