指定した XY 座標値を中心にマップを移動する方法

      2017/12/09

'******************************************************************************
' 定義 :fncMapMove(X As Double, Y As Double)
' 概要 :指定したXY座標を中心にマップを移動
' 第1引数 :Double
' 第2引数 :Double
' 戻り値 :なし
'
' 製品 :ArcGIS Desktop 9.1 ArcView
' ライブラリ :ArcMapUI, Carto, Display, Geometry,
' クラス :MxDocument, Map, ScreenDisplay, Envelope, DisplayTransformation
' インタフェース:IMxDocument, IActiveView, IScreenDisplay, IEnvelope, IDisplayTrnsformaiton
' メンバ :IMxDocument::ActiveView, IActiveView::ScreenDisplay, IScreenDisplay::DsplayTransformation
'
' 更新履歴 :2005/12/06 新規作成
'******************************************************************************
Private Function fncMapMove(X As Double, Y As Double)
 
'現在のDocumentを取得
Dim pMxDocument As IMxDocument
Set pMxDocument = ThisDocument
 
'ActiveViewの取得
Dim pActiveView As IActiveView
Set pActiveView = pMxDocument.ActiveView
 
'ScreenDisplayの取得
Dim pScreenDisplay As IScreenDisplay
Set pScreenDisplay = pActiveView.ScreenDisplay
 
'ActiveViewからEnvelopeを作成
Dim pEnvelope As IEnvelope
Set pEnvelope = pActiveView.Extent
 
'画面移動後のEnvelopeを新規作成
Dim pNewEnvelope As IEnvelope
Set pNewEnvelope = New Envelope
 
pNewEnvelope.XMin = X - pEnvelope.Width / 2
pNewEnvelope.YMin = Y - pEnvelope.Height / 2
pNewEnvelope.XMax = X + pEnvelope.Width / 2
pNewEnvelope.YMax = Y + pEnvelope.Height / 2
 
'移動後のEnvelopeを画面に設定
Dim pDisplayTransformation As IDisplayTransformation
Set pDisplayTransformation = pScreenDisplay.DisplayTransformation
 
pDisplayTransformation.VisibleBounds = pNewEnvelope
 
'マップの再描画
pActiveView.Refresh
 
End Function
 
'参考
' http://edndoc.esri.com/arcobjects/8.3/ComponentHelp/esriCore/ZoomInCenter.htm

 - プログラミング, ArcGIS , ,