<< Click to Display Table of Contents >> Navigation: 3D API 說明範例 > 功能 > 基本控制項 > 地圖瀏覽限制 |
<說明>
在本範例中,我們將示範如何使用地圖瀏覽限制,說明如下:
<範例>
var earth_ = null; var earth_ = null; 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); 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");
// 設定目前 Camera 位置, 參數為: 經度, 緯度, 高程(公尺), 方位角, 傾角, 是否動畫展示 pEarth.SetViewpoint(121.25, 24.82, 500000, 0, 0, false);
var pCam = pEarth.GetCamera(); pCam.addEventListener("changed", CameraChanged, false); // Camera 狀態改變時觸發 }
function CameraChanged(tEvent) { var pCam = earth_.GetCamera(); // 當 Camera 的位置超出指定範圍, 強制將其移至指定位置 if (pCam.Position.X < 120 || pCam.Position.X > 122 || pCam.Position.Y < 20 || pCam.Position.Y > 25) earth_.SetViewpoint(121.25, 24.82, pCam.Position.Z, 0, 0, false); } }
|
© 2017 Supergeo Technologies Inc.