除了在SDK中寫死輸入的點(diǎn)線面之外箱吕,常用的就是繪制模式芥驳,繪制模式中潮峦,點(diǎn)的繪制比較麻煩鲤孵,線面的繪制比較簡單。
1.點(diǎn)的繪制
由于通常的繪制習(xí)慣都是鼠標(biāo)左鍵打點(diǎn)隧出,但是在日常的時(shí)候怎栽,左鍵經(jīng)常會(huì)使用到丽猬,因此如果直接進(jìn)行繪制點(diǎn)的話,不能區(qū)分是拖動(dòng)地圖還是進(jìn)入繪制的狀態(tài)熏瞄。
1.1設(shè)置一個(gè)全局的點(diǎn)
Point Location_MouseDown;
1.2判定這個(gè)點(diǎn)是否就是繪制的點(diǎn)脚祟,即判定鼠標(biāo)左鍵放下和抬起是否在同一個(gè)位置
globeControl1.Globe.Action = EnumAction3D.NormalHit;//鼠標(biāo)瀏覽的狀態(tài)
? ? ? ? ? ? globeControl1.MouseUp += (sender2, e2) =>
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Location_MouseDown = e2.Location;
? ? ? ? ? ? };
? ? ? ? ? ? globeControl1.MouseUp += (sender2, e2) =>
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (Location_MouseDown != e2.Location) return;
? ? ? ? ? ? ? ? if (e2.Button == MouseButtons.Left)
1.3若果確認(rèn)為是這個(gè)點(diǎn),那么獲取這個(gè)點(diǎn)强饮,這個(gè)點(diǎn)作為一個(gè)要素由桌,添加到內(nèi)存圖層中。
if (globeControl1.Globe.Action == EnumAction3D.NormalHit)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? GSOPoint3d point3d = new GSOPoint3d();
? ? ? ? ? ? ? ? ? ? ? ? GSOFeature newFeature = new GSOFeature();
? ? ? ? ? ? ? ? ? ? ? ? GSOGeoMarker p = new GSOGeoMarker();
? ? ? ? ? ? ? ? ? ? ? ? GSOMarkerStyle3D style = new GSOMarkerStyle3D();
? ? ? ? ? ? ? ? ? ? ? ? style.IconPath = Application.StartupPath + "/Resource/image/DefaultIcon.png";
? ? ? ? ? ? ? ? ? ? ? ? p.Style = style;
? ? ? ? ? ? ? ? ? ? ? ? p.Z = point3d.Z <= 0 ? 0 : point3d.Z;
? ? ? ? ? ? ? ? ? ? ? ? if (point3d.Z <= 0.0)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? point3d = globeControl1.Globe.ScreenToScene(e2.X, e2.Y);
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? p.X = point3d.X;
? ? ? ? ? ? ? ? ? ? ? ? p.Y = point3d.Y;
? ? ? ? ? ? ? ? ? ? ? ? p.Z = point3d.Z;
? ? ? ? ? ? ? ? ? ? ? ? p.Text = "標(biāo)注";
? ? ? ? ? ? ? ? ? ? ? ? newFeature.Geometry = p;
? ? ? ? ? ? ? ? ? ? ? ? newFeature.Name = "我的地標(biāo)";
? ? ? ? ? ? ? ? ? ? ? ? globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
? ? ? ? ? ? ? ? ? ? ? ? globeControl1.Globe.Action = EnumAction3D.ActionNull;
? ? ? ? ? ? ? ? ? ? ? ? globeControl1.Globe.FlyToFeature(newFeature);
? ? ? ? ? ? ? ? ? ? ? ? globeControl1.Refresh();
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? };
相關(guān)代碼
相關(guān)代碼