<< Click to Display Table of Contents >>
<說明>
SuperGIS 3D API提供一系列的地圖事件,以改變地圖類型而觸發動作,監聽在地圖上觸發的事件,function是可自訂的函式,詳細設定可參照範例。
<範例>
var earth_ = null; function documentLoad() { document.body.style.overflow = "hidden"; 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); 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.SetViewpoint(121.25, 24.82, 500000, 0, 0, true);
var pCam = pEarth.GetCamera(); pCam.addEventListener("changed", CameraChanged, false); // Camera 狀態改變時觸發 }
function CameraChanged(tEvent) { var pCam = earth_.GetCamera(); // 由 Camera 的狀態可以得知球面如何被改變 var pos = pCam.Position; // Camera 的位置坐標為 Earth 的坐標系統 (X, Y, Z), Z 為高度 (公尺) var v1 = pCam.Pitch; // X 軸旋轉角度, 一般所知的傾角 (Tilt) var v2 = pCam.Roll; // Y 軸旋轉角度, 固定限制為 0 var v3 = pCam.Yaw; // Z 軸旋轉角度, 一般所知的方位角, 朝正北為 0
var msg = "Camera Status: X: " + parseFloat(pos.X).toFixed(6) + ", Y: " + parseFloat(pos.Y).toFixed(6) + ", Z: " + parseFloat(pos.Z).toFixed(6) + ", Pitch: " + parseFloat(v1).toFixed(2) + ", Roll: " + parseFloat(v2).toFixed(2) + ", Yaw: " + parseFloat(v3).toFixed(2); document.getElementById("result").innerHTML = msg; } }
|
© 2017 Supergeo Technologies Inc.