Professional Documents
Culture Documents
Bing Google From MXD
Bing Google From MXD
I only made minor changes and added a few different Google/Bing choices.
Nick Harrison. Dec 2009
Part I. Paste code into VBA Editor
1) From the ArcMap menu, navigate to Tools --> Macros --> Visual Basic Editor
to open the
VBA editor
2) In the VBA Editor's Project Window, expand either the Normal (Normal.mxt)
or the
Project (YourMXDName.mxd) --> Arcmap Objects folder and double click on
ThisDocument
Note: If you want the code accessible in every MXD you open place the code
in the Normal.mxt;
If you only want it in a specific MXD then place it in the project.
3) Paste the code (below) in the window that opens and close the VBA editor.
4) Save your project
Part II. Create and configure custom ArcMap Tool
1) From the ArcMap menu, navigate to Tools -->Customize
2) Click the Commands tab.
3) Click the drop-down arrow on the Save in combo box, then change the
selected item so it is
either the Normal.MXD or the current name of your ArcMap project (ex.
Untitled.mxd) depending
on where you placed the code in part I.
4) Click [UIControls] in the Categories list. then Click the New UIControl
button.
5) Click the UIToolControl radio button and then click Create.
6) The name of the new tool appears in the Commands list. Single click the
newly created UIControl,
then click it again to activate in-place editing, then type a new name for
the control so it reads
Normal.GoogleMap_Link or Project.GoogleMap_Link depending on where you put
the code.
7) Click and drag the newly created UIControl and drop it on an ArcMap toolbar
or menu.
8) With the Customize dialog still open, on the toolbar or menu, right-click
the command to set its
SW_SHOWMAXIMIZED = 3
SW_SHOWMINIMIZED = 2
SW_SHOWDEFAULT = 10
SW_SHOWMINNOACTIVE = 7
SW_SHOWNORMAL = 1
pMxDoc As IMxDocument
pApp As IMxApplication
pMap As IMap
pPoint As IPoint
pSpatialReferenceFactory As ISpatialReferenceFactory
pSpatialReference As ISpatialReference
Case 6
'GOOGLE MAP - HYBRID
URLstr = "http://www.google.com/maps?ie=UTF8&ll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) _
& "&z=17&t=h"
Case 7
'BING MAPS - HYBRID
URLstr = "http://www.bing.com/maps/default.aspx?v=2&cp=" _
& Round(pPoint.y, 6) & "~" & Round(pPoint.x, 6) _
& "&lvl=17&style=h"
Case 2
Exit Sub
End Select
'Use one of the constants as the window state parameter
returnLong = OpenLocation(URLstr, SW_SHOWNORMAL)
' URL CODE FOR OTHER POSSIBILITIES:
'more info on google map URL query string request setting parameters:
'http://mapki.com/index.php?title=Google_Map_Parameters
'more info on BING URL query string request setting parameters:
'http://www.bing.com/community/blogs/maps/archive/2008/04/10/live-searchmaps-api.aspx
'GOOGLE MAP - HYBRID
'URLstr = "http://www.google.com/maps?ie=UTF8&ll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) _
& "&z=17&t=h"
'GOOGLE MAP - STREET VIEW
'URLstr = "http://www.google.com/maps?ie=UTF8&layer=c&cbll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) &
"&cbp=1,0,,0,5&ll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) & "&z=17"
'GOOGLE MAP - STREET VIEW WITH MAP - SPLIT SCREEN
'URLstr = "http://www.google.com/maps?ie=UTF8&layer=c&cbll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) &
"&cbp=11,0,,0,5&ll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) & "&t=h&z=17"
'GOOGLE MAP - STREET VIEW WITH MAP - LOWER RIGHT CORNER
'URLstr = "http://www.google.com/maps?ie=UTF8&layer=c&cbll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) &
"&cbp=12,0,,0,5&ll=" _
& Round(pPoint.y, 6) & "," & Round(pPoint.x, 6) & "&t=h&z=17"
'BING MAPS - HYBRID
' URLstr = "http://www.bing.com/maps/default.aspx?v=2&cp=" _
& Round(pPoint.y, 6) & "~" & Round(pPoint.x, 6) _
& "&lvl=17&style=h"