You are on page 1of 2

Private WithEvents m_pMap As Map Private m_pIE As Object

Private Sub m_pMap_ViewRefreshed(ByVal view As esriCarto.IActiveView, ByVal phas e As esriCarto.esriViewDrawPhase, ByVal Data As Variant, ByVal envelope As esriG eometry.IEnvelope) Dim pPoint As IPoint Set pPoint = New Point pPoint.X = (view.Extent.XMax + view.Extent.XMin) / 2 pPoint.Y = (view.Extent.YMax + view.Extent.YMin) / 2 Dim lat As Double Dim lon As Double Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument PointToLatLon pMxDoc, pPoint, lat, lon Dim n As Double n = Round(pMxDoc.FocusMap.MapScale) / 5.82 m_pIE.Document.parentWindow.execScript "ZoomTo(" & lat & "," & lon & "," & n & " );", "javascript" End Sub

Private Sub UIButtonControl1_Click() Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Set m_pMap = pMxDoc.FocusMap Set m_pIE = CreateObject("InternetExplorer.Application") m_pIE.Visible = True m_pIE.navigate2 "C:\Users\anwar.sabbagh\Desktop\GE_ArcGIS\test\Ge.htm" End Sub Function PointToLatLon(pMxDocument As IMxDocument, ByVal pPoint As IPoint, ByRef dLatitude As Double, ByRef dLongitude As Double) On Error GoTo EH: ' variables for dealing with projections and units Dim pSpRefOutput As esriGeometry.ISpatialReference Dim pSpRefInput As esriGeometry.ISpatialReference ' set the spatial reference of output KML data Dim pSpRFc As esriGeometry.SpatialReferenceEnvironment Dim pGCS As esriGeometry.IGeographicCoordinateSystem Set pSpRFc = New esriGeometry.SpatialReferenceEnvironment Set pGCS = pSpRFc.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984) Set pSpRefOutput = pGCS

pSpRefOutput.SetFalseOriginAndUnits -180, -90, 1000000 Dim pGeometry2 As IGeometry2 Set pGeometry2 = pPoint Set pSpRefInput = pMxDocument.FocusMap.SpatialReference ' project feature into latitude/longtitude if necessary Set pGeometry2.SpatialReference = pSpRefInput pGeometry2.Project pSpRefOutput Dim pNewPoint As IPoint Set pNewPoint = pGeometry2 dLatitude = pNewPoint.X dLongitude = pNewPoint.Y EH: End Function

You might also like