<< Click to Display Table of Contents >>
<說明>
在設定好一組線資料後,必須藉由API中SGELine類別的方法加以呈現,並決定線資料的樣式,包含是否顯示、是否可點擊、顏色、筆畫寬度、筆畫透明度、堆疊順序等,以及滑鼠的觸發事件,以下為設定線圖徵筆畫寬度、顏色及堆疊順序的範例。
<範例>
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"); pEarth.MajorGraticule.Visible = false; pEarth.MinorGraticule.Visible = false;
// 指定向量磚服務的 WMTS 網址, 欲加入的圖層名稱, 及 callback function 名稱 VLayer = new SuperGIS.VectorLayer(getDataServicePath() + 'project_line/SimpleWMTS.aspx', pEarth, { layer: '管線' }, PipeFinish);
pEarth.SetViewpoint(120.656, 24.160, 500, 0, 50, true); }
// 在 callback 中設定每個 feature 的符號樣式 function PipeFinish(array) { var rv = 128, gv = 255, bv = 128; for (var i = 0; i < array.length; i++) { var mark = array[i]; var depth = mark.GetFieldValue("高");
var LSym = null;
if (depth == 1) { var fc = earth_.CreateColor(1, 1, 0, 0.5); LSym = earth_.CreateSimpleDDDLineSymbol(new SuperGIS.DDDCore.Material(fc, 0, 1)); // 一般單線符號, Material 參數: color; cullface: 0, 1, 2; width: 1 (固定值) } else if (depth == 2) { var fc = earth_.CreateColor(0.75, 0.5, 0.5, 0.5); LSym = earth_.CreateRoundPipeSymbol(earth_.CreateModelMaterial(0, fc), 1, 1); // 圓形管線符號, 末兩參數: 管徑, ratio } else { var fc = earth_.CreateColor(0.5, 0.75, 0.5, 0.5); LSym = earth_.CreateSquarePipeSymbol(earth_.CreateModelMaterial(0, fc), 1.5, 1); // 方形管線符號 }
mark.ReplaceZ = -depth; // 設定高程 (公尺, 負值為地下) mark.DDDSymbol = LSym; } } }
|
© 2017 Supergeo Technologies Inc.