查詢工具

<< Click to Display Table of Contents >>

Navigation:  3D API 說明範例 > 功能 > 查詢 >

查詢工具

 

 

檢視範例

範例下載

 

 

<說明>

在本範例中,我們將示範如何呼叫查詢工具,說明如下:

 

 

<範例>

 function documentLoad()

         {

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

                 {

                         SuperGIS.ServerEarth.Initialize(InitEarth);

                 });

         }

         function InitEarth()

         {

                 var pBody = new SuperGIS.Windows.HTMLContainer(document.body);

 

                 var sHost = location.href;

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

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

                 var pSGServer = new SuperGIS.Server.SGServer(sHost + "/ServerGate/SGSGate.ashx", false);

                 pSGServer.GetApp(SGS3DEarth.GUID, function (pApp)

                 {

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

                         {

                                 CreatePluginEarth(pBody, function (pEarth) { EarthLoaded(pEarth, pApp); });

                         });

                 });

 

                 function EarthLoaded(pEarth, pApp)

                 {

                         var sHost = location.href;

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

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

 

                         var sHref = location.href;

                         idx = sHref.lastIndexOf("/");

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

 

                         var IsCube = true;

                         if (pApp != null)

                                 IsCube = pApp.getIsCube();

                         if (IsCube)

                         {

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

                                 pEarth.SetupSystem(false, null);

                         }

                         else

                         {

                                 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");

                                 if (navigator.geolocation)

                                 {

                                         navigator.geolocation.getCurrentPosition(function (pos)

                                         {

                                                 var pGlobe = pEarth.GetGlobe();

                                                 var dSMA = pGlobe.GetSemiMajorAxis()

                                                 var dRadius = pos.coords.accuracy / dSMA;

                                                 var dAltitude = dSMA * (Math.sin(dRadius) / Math.tan(Math.PI / 8.0) + Math.cos(dRadius) - 1) * 4;

                                                 var pTour = pEarth.CreateTourAction();

                                                 pTour.AddTourPoint(5, pEarth.CreateLatLonAlt(pos.coords.latitude, pos.coords.longitude, dAltitude), 0, 0, 0);

                                                 pEarth.StartNavigate(pTour, 0);

                                         });

                                 }

                         }

                         var pGlobe = pEarth.GetGlobe();

 

                         var pSPnl = pEarth.CreateStatusPanel();

                         var pNPnl = pEarth.CreateNavigationPanel();

                         var pTPnl = pEarth.CreateToolbarPanel(0, 0, 0);

                         pEarth.AddPanel(pSPnl);

                         pEarth.AddPanel(pNPnl);

                         pEarth.AddPanel(pTPnl);

 

                         if (pApp != null)

                         {

                                 if (pEarth.MajorGraticule != null)

                                         pEarth.MajorGraticule.Visible = pApp.getGraticule();

                                 if (pEarth.MinorGraticule != null)

                                         pEarth.MinorGraticule.Visible = pApp.getGraticule();

                                 pGlobe.AltitudeExaggeration = pApp.getExaggeration();

                                 //pEApp.TableOfContentsVisible = pApp.getTableOfContents() ? 1 : 0;

                                 var strCopyright = pApp.getCopyright();

                                 if (strCopyright != null && strCopyright != "")

                                         pSPnl.CopyrightText = strCopyright;

                                 pNPnl.Visible = pApp.getControler();

                                 pTPnl.Visible = pApp.getToolbar();

                                 pTPnl.SetBackgroundImage(sHref + "/images/Tool_01.png", "", sHref + "/images/Tool_08.png");

                                 if (pApp.getIndexMap())

                                         pTPnl.AddTool(pEarth.CreateIndexview(), sHref + "/images/Tool_02.png", sHref + "/images/Tool2_02.png");

                                 if (pApp.getAddGeometries())

                                         pTPnl.AddTool(pEarth.CreateCommandPaint(), sHref + "/images/Tool_03.png", sHref + "/images/Tool2_03.png");

                                 if (pApp.getAddKml())

                                         pTPnl.AddTool(pEarth.CreateCommandAddKML(sHost + "/ServerGate/pushpin.png"), sHref + "/images/Tool_04.png", sHref + "/images/Tool2_04.png");

                                 if (pApp.getMeasurements())

                                         pTPnl.AddTool(pEarth.CreateCommandMeasure(), sHref + "/images/Tool_05.png", sHref + "/images/Tool2_05.png");

                                 if (pApp.getShare())

                                         pTPnl.AddTool(pEarth.CreateCommandShare(), sHref + "/images/Tool_06.png", sHref + "/images/Tool2_06.png");

                                 if (pApp.getQuery())

                                         pTPnl.AddTool(pEarth.CreateCommandQuery(), sHref + "/images/Tool_07.png", sHref + "/images/Tool2_07.png");

                                 pTPnl.AddTool(pEarth.CreateCommandConfig(), sHref + "/images/Tool_09.png", sHref + "/images/Tool2_09.png");

 

                                 var bInit = true;

                                 var sResources = pApp.getResources();

                                 for (var i = sResources.length - 1; i >= 0; i--)

                                 {

                                         var pSRes = pSGServer.GetResource(sResources[i]);

                                         if (pSRes == null)

                                                 continue;

                                         var pEnv = pSRes.getTileEnvelope();

                                         var pSRef = pEnv.getSpatialReference();

                                         if (IsCube && bInit && pSRef != null)

                                         {

                                                 var pSEnv = pEarth.CreateEnvelope(pEnv.Left, pEnv.Right, pEnv.Bottom, pEnv.Top, pSRef);

                                                 pEarth.SetupSystem(false, pSRef);

                                                 pEarth.SetupSkin(pSEnv, null);

                                                 bInit = false;

                                         }

                                         pEarth.Objects.Add(new SuperGIS.ServerEarth.ResourceLayer(pEarth, pSGServer, pSRes, 0));

                                 }

                         }

                         pEarth.SetCurrentViewExtent(pEarth.GetFullExtent());

                         pEarth.Invalidate();

                 }

         }

 

 

 

 

 


© 2017 Supergeo Technologies Inc.