Integrating the GPV - AppGeo/GPV GitHub Wiki
Web Integration
Here's a sample clickable google map that links to the GPV: http://gis.amherstma.gov/beta/googleclickablemap.htm replicating this requires a Google Map API Key, which is free.
ArcGIS Desktop Integration
Some ArcGIS Desktop tools for interfacing with the GPV
Identify from ArcMap using the GPV Identify Window (AKA Super Identify Tool)
This tool was developed using VBA. To use in ArcMap, paste this code into the ThisDocument area for an MXD or the Normal.mxt in the ArcMap VBA Editor. Then, create a UIToolControl named SuperID, or the name of your choice (rename SuperID in the code below to match the button name).
Public Sub SuperID_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pMxApp As IMxApplication
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pMapsActiveView As IActiveView
Dim pPoint As esriGeometry.IPoint
Dim strURL As String
Dim strApp As String
Set pMxApp = Application
Set pDoc = Application.Document
Set pMap = pDoc.FocusMap
Set pMapsActiveView = pMap
'This is the base url:
strApp = "http://gis.amherstma.gov/public/Identify.aspx?maptab=UtilityBaseMap&distance=4&scale=2&x="
'Convert x and y to map units
Set pPoint = pMapsActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
'This is the final url, which includes the x&y coordinates appended by the onclick event
strURL = strApp & CStr(pPoint.x) & "&y=" & CStr(pPoint.y)
'This opens the final url in your default web browser
ShellExecute Application.hwnd, vbNullString, strURL, vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Public Function SuperID_Message() As String
'Information displayed when mouse over the button
SuperID_Message = "Identify Features Using the Amherst GIS Viewer Interface (includes utilities)"
End Function
Public Function SuperID_ToolTip() As String
'Information displayed when mouse over the button
SuperID_ToolTip = "Identify Features with the Amherst GIS Viewer"
End Function
Public Function SuperID_CursorID() As Variant
'Sets the cursor display.
SuperID_CursorID = 3
End Function
Open GPV from ArcMap at the current map extent
This tool was developed using VBA. To use in ArcMap, paste this code into the ThisDocument area for an MXD or the Normal.mxt in the ArcMap VBA Editor. Then, create a UIButtonControl named AmherstGisViewer, or the name of your choice (rename AmherstGisViewer in the code below to match the button name).
Public Sub AmherstGisViewer_Click()
'ArcGIS map parameters
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pMapsActiveView As IActiveView
Dim pEnvelope As IEnvelope
'GPV parameters
Dim strURL As String
Dim strApp As String
'Set the ArcMap values
Set pMxDoc = Application.Document
Set pMap = pMxDoc.FocusMap
Set pMapsActiveView = pMap
Set pEnvelope = pMapsActiveView.Extent
'This is the gpv application url:
strApp = "http://gis.amherstma.gov/public/viewer.aspx?application=ParcelApp&maptab=UtilityBaseMap"
'Ensures that there is a valid envelope
If pEnvelope.LowerLeft.x < 0 Then
strURL = strApp
Else
strURL = strApp & "&keepurl=1&extent=" & CStr(pEnvelope.LowerLeft.x) & "," & CStr(pEnvelope.LowerLeft.y) & "," & _
CStr(pEnvelope.UpperRight.x) & "," & CStr(pEnvelope.UpperRight.y)
End If
'This opens the GPV in your default web browser
ShellExecute Application.hwnd, vbNullString, strURL, vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Public Function AmherstGisViewer_Message() As String
'Information displayed when mouse over the button
AmherstGisViewer_Message = "Open the Amherst GIS Viewer at the Current Extent"
End Function
Public Function AmherstGisViewer_ToolTip() As String
'Information displayed when mouse over the button
AmherstGisViewer_ToolTip = "Open the Amherst GIS Viewer at the Current Extent"
End Function
Open the Pictometry Viewer from ArcMap at the current map extent using Latitude and Longitude
This tool was developed using VBA. The purpose of posting this here is to demonstrate how to use latitude and Longitude to open the GPV. This example actually opens the Amherst Pictometry Viewer, which is similar to the GPV. This code can be adapted to open the GPV instead. To use in ArcMap, paste this code into the ThisDocument area for an MXD or the Normal.mxt in the ArcMap VBA Editor. Then, create a UIToolControl named AmherstLatLon, or the name of your choice (rename AmherstLatLon in the code below to match the button name).
Private Sub AmherstLatLon_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pMxDoc As IMxDocument
Dim pPoint As IPoint
Dim pClone As IClone
Dim pGeometry As IGeometry
Dim pSpatialRefFactory As ISpatialReferenceFactory
Dim pSpatialRef As ISpatialReference
Dim pGeographicCoordSys As IGeographicCoordinateSystem
Dim strURL As String
Dim strApp As String
'Get the point where the user clicked
Set pMxDoc = Application.Document
If pMxDoc.CurrentLocation.IsEmpty Then Exit Sub
'Clone the point because we don't want to alter
'the actual document's current location point
Set pClone = pMxDoc.CurrentLocation
Set pPoint = pClone.Clone
Set pGeometry = pPoint 'QI
'Create a new geographic coordinate system to use in the conversion
Set pSpatialRefFactory = New SpatialReferenceEnvironment
Set pGeographicCoordSys = pSpatialRefFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_NAD1983)
Set pSpatialRef = pGeographicCoordSys 'QI
pSpatialRef.SetFalseOriginAndUnits -180, -90, 1000000
pGeometry.Project pSpatialRef
'This is the base url:
strApp = "http://gis.amherstma.gov/public/pictometry/viewer.aspx?lon="
'This is the final url, which includes the x&y coordinates appended by the onclick event
strURL = strApp & CStr(pPoint.x) & "&lat=" & CStr(pPoint.y)
'This opens the final url in your default web browser
ShellExecute Application.hwnd, vbNullString, strURL, vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Public Function AmherstLatLon_Message() As String
'Information displayed when mouse over the button
AmherstPictometry_Message = "Open the GPV With Lat Lon"
End Function
Public Function AmherstLatLon_ToolTip() As String
'Information displayed when mouse over the button
AmherstPictometry_ToolTip = "Open the GPV With Lat Lon"
End Function
Public Function AmherstLatLon_CursorID() As Variant
'Sets the cursor display.
AmherstPictometry_CursorID = 3
End Function