<< Click to Display Table of Contents >> Navigation: 3D API 說明範例 > 圖層套疊 > 標記 > 標記文字樣式 |
<說明>
修改標記文字大小、顏色及字型等格。
<範例>
function documentLoad() { SuperGIS.Initialize("/ServerGate/", function () { SuperGIS.ServerEarth.Initialize(InitEarth); }); }
var marker_ = null; 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) { 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;
var sHref = location.href; idx = sHref.lastIndexOf("/"); if (idx >= 0) sHref = sHref.substring(0, idx); var iconurl = sHref + "/marker.png"; // 設定 icon url, 若為空字串, 表示不使用 icon, 僅單純顯示文字
var loc = SuperGIS.DDDEarth.LatLonAlt.NewLatLonAlt(24.160, 120.656, 44); // 定義標記 X, Y, Z
var marker = new SuperGIS.Marker(pEarth, loc, "TestMarker", iconurl, { Hitable: true, HaloColor: { r: 0, g: 0, b: 0, a: 255 }, TextColor: { r: 255, g: 255, b: 255, a: 255 }, FontSize: 12 }); // 建立標記物件 // Hitable: 設定是否可點擊 // TextColor: 設定文字顏色 // HaloColor: 設定暈圈顏色 // FontSize: 設定文字大小 // 輸入的文字若欲換行, 可插入 "\n" 字元, 如 "Test\nMarker"
marker_ = marker;
var pm = marker.getPlacemark(); // 自標記物件中取回 Placemark 物件 pm.Visible = true; // 設定顯示與否 (預設為 true)
pm.ExtrudeSymbol = pEarth.CreateSimpleDDDLineSymbol(pEarth.CreateModelMaterial(0, pEarth.CreateColor(1, 0, 0, 1))); // 設定垂直線符號, 若不設定即不顯示
pEarth.SetViewpoint(120.656, 24.159, 200, 0, 45, true);
//加入監聽事件方法 SuperGIS.Event.addListener(marker, "title_changed", OnTitleChanged); // 文字改變時觸發 SuperGIS.Event.addListener(marker, "position_changed", OnPositionChanged); // 位置改變時觸發 SuperGIS.Event.addListener(marker, "icon_changed", OnIconChanged); // icon 改變時觸發
pEarth.addEventListener("mousedown", mousedownTest, false); // 滑鼠鍵按下時觸發
} function mousedownTest(tEvent) { var bHit = marker_.hitTest(tEvent.x, tEvent.y); // 測試標記是否被點擊到 if (bHit) marker_.remove(); // 移除此標記 } function OnTitleChanged() { } function OnPositionChanged() { } function OnIconChanged() { } }
|
© 2017 Supergeo Technologies Inc.