tags:

views:

27

answers:

0

Hi, I am changing a script that is used in ArcMap to create a UIControltool, which allows you that an available StreetView at a given coordinate in your Map pop-ups, to the ArcScene environment. I have the following problem: google opens but not at the right coordinates. I think there is an error in my definition of the spatial reference for ArcScene, but I do not know where...can somebody help?

Here is the script:

Option Explicit

Const SW_SHOWMAXIMIZED = 3 Const SW_SHOWMINIMIZED = 2 Const SW_SHOWDEFAULT = 10 Const SW_SHOWMINNOACTIVE = 7 Const SW_SHOWNORMAL = 1

Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hWnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long

Private Function OpenLocation(URL As String, WinState As Long) As Long

'PURPOSE: Opens default browser to display URL 

'RETURNS: module handle to executed application or 
'Error Code ( < 32) if there is an error 

'can also be used to open any document associated with 
'an application on the system (e.g., passing the name 
'of a file with a .doc extension will open that file in Word) 

Dim lHWnd As Long 
Dim lAns As Long 

lAns = ShellExecute(lHWnd, "open", URL, vbNullString, _ 
vbNullString, WinState) 

OpenLocation = lAns 

'ALTERNATIVE: if not interested in module handle or error 
'code change return value to boolean; then the above line 
'becomes: 

'OpenLocation = (lAns > 32) 
End Function

Private Sub GoogleMap_Link_MouseDown(ByVal button As Long, ByVal shift _ As Long, ByVal x As Long, ByVal y As Long)

Dim pSXDoc As ISxDocument 
Dim pApp As ISxApplication 
Dim pActiveView As IActiveView 
Dim pScene As IScene 
Dim pPoint As IPoint 
Dim pSpatialReferenceFactory As ISpatialReferenceFactory 
Dim pSpatialReference As ISpatialReference 

Set pSXDoc = ThisDocument 
Set pScene = pSXDoc.Scene 
Set pActiveView = pScene 
Set pApp = Application 

Set pSpatialReferenceFactory = New SpatialReferenceEnvironment 
Set pSpatialReference = pSpatialReferenceFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984) 


' convert mouse click to map units 
Set pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y) 
Set pPoint.SpatialReference = pScene.SpatialReference 
If pPoint.SpatialReference.Name <> pSpatialReference.Name Then 
    pPoint.Project pSpatialReference 

End If 

Dim URLstr As String 
Dim returnLong As Long 
'more info on google map URL query string request setting parameters: 'http://mapki.com/index.php?title=Google_Map_Parameters

'STREET VIEW USE THIS FUNCTION 
URLstr = "http://www.google.com/maps?ie=UTF8&amp;layer=c&amp;cbll=" & _ 
         pPoint.y & "," & pPoint.x & "&cbp=1,0,,0,5&ll=" & pPoint.y _ 
         & "," & pPoint.x & "&z=16" 

'REGULAR MAP USE THIS FUNCTION ... NO STREETVIEW WINDOW 
'URLstr = "http://www.google.com/maps?ie=UTF8&amp;ll=" & pPoint.y _ 
         & "," & pPoint.x & "&spn=0.015045,0.016844&z=16" 

'Use one of the constants as the window state parameter 
returnLong = OpenLocation(URLstr, SW_SHOWNORMAL) 
End Sub