VC MapX鷹眼實現

2021-04-12 20:58:04 字數 2306 閱讀 5385

我的基本實現想法是,在同乙個view視窗下家兩個cmapx控制項,乙個稱為主圖,乙個稱為鷹眼圖。

cmapx m_ctrlmapx; ///主圖

cmapx m_eaglemapx; ///鷹眼圖

注意事項:在view裡的oncreate函式一定要想建立m_eaglemapx,這樣才能看見鷹眼圖。既如此:

m_eaglemapx.create(null, ws_visible, crect(0, 0, 120, 120), this, idc_map_eagle);

m_eaglemapx.setgeoset(null);

m_ctrlmapx.create(null, ws_visible, crect(0, 0, 100, 100), this, idc_map);

m_ctrlmapx.setgeoset(null);

接下來,可以在主圖里挑幾層加到鷹眼圖中(區域圖層)

再在訊息中對映幾個訊息:

on_event(cmtrsview, idc_map_eagle, dispid_mousemove /* mousemove */, onmousemoveeaglemap, vts_i2 vts_i2 vts_r4 vts_r4)

on_event(cmtrsview, idc_map_eagle, dispid_mousedown /* mousedown */, onmousedowneaglemap, vts_i2 vts_i2 vts_r4 vts_r4)

on_event(cmtrsview, idc_map_eagle, dispid_mouseup /* mouseup */, onmouseupeaglemap, vts_i2 vts_i2 vts_r4 vts_r4)

最後實現這幾個函式:

void cmtrsview::onmouseupeaglemap(short button, short shift, float x, float y)

///使用者在導航圖上框出矩形區域時的處理

if(strmousestate == "move")

else

if(prex < y)

else

double dblxmax, dblxmin, dblymax, dblymin;

m_eaglemapx.convertcoord(&sngxmin, &sngymin, &dblxmin, &dblymin, miscreentomap);

m_eaglemapx.convertcoord(&sngxmax, &sngymax, &dblxmax, &dblymax, miscreentomap);

cmapxrectangle rect;

rect.createdispatch(rect.getclsid());

rect.set(dblxmin, dblymin, dblxmin, dblymax);

m_ctrlmapx.setbounds(rect.m_lpdispatch);

}strmousestate = "stop";

}void cmtrsview::onmousedowneaglemap(short button, short shift, float x, float y)

if(button == vbleftbutton)

void cmtrsview::onmousemoveeaglemap(short button, short shift, float x, float y)

///在導航圖鷹眼層畫虛線矩形框,框出使用者預選擇的範圍

cmapxfeature ftrmap;

colevariant pntsvt, styvt;

pntsvt.vt = vt_dispatch;

pntsvt.pdispval = pnt**ap.m_lpdispatch;

pntsvt.pdispval->addref();

styvt.vt = vt_dispatch;

styline.createdispatch(styline.getclsid());

styvt.pdispval = styline.m_lpdispatch;

styvt.pdispval->addref();

ftrmap = m_eaglemapx.getfeaturefactory().createline(pntsvt, styvt);

m_eaglemapx.getlayers().item("eaglelayer").addfeature(ftrmap);

///設定滑鼠狀態為"move"

strmousestate = "move";

}還有,可以在onsize裡面設定一下鷹眼圖的大小.

AE 中鷹眼實現

private void axmapcontrol1 onmapreplaced object sender,imapcontrolevents2 onmapreplacedevent e 同步mapcontrol1 與 2 else axmapcontrol2.loadmxfile axmapco...

ArcEngine9 3的鷹眼實現

主地圖控制項的extentupdated事件激發時,要隨之改變鷹眼地圖視窗中的框的位置和大小。函式為 鷹眼程式,根據主地圖視窗的extent,在鷹眼地圖中繪製element private void createelementforeaglemap ienvelope penv 將主窗體的exten...

MapX系列 鷹眼

鷹眼 map物件的ctlbounds 是當前可視地圖區域的邊框矩形,可以用 ctlbounds 生成鷹眼。if not m mxmapee is nothing then dim mxpoints as new mapxlib.points dim mxrectangle as new mapxli...