Hi,
I'm in the process of trying to figure out how to convert our Google Streeview tool from a 10.2 Add-In to an ArcPro Add-In. The code is below for 10.2. If anyone can help me figure out how to convert it, it would be much appreciated.
After adding the tool to ArcMap, you just click on the tool, then click on the map and streetview open in a web browser. Pretty simple.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
namespace GoogleStreetView_Add_In
{
public class GoogleStreetView : ESRI.ArcGIS.Desktop.AddIns.Tool
{
private ESRI.ArcGIS.Carto.IActiveView activeView;
public GoogleStreetView()
{
}
protected override void OnUpdate()
{
Enabled = ArcMap.Application != null;
}
protected override void OnMouseDown(MouseEventArgs arg)
{
ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (IMxDocument)ArcMap.Document;
activeView = (ESRI.ArcGIS.Carto.IActiveView)mxDoc.FocusMap;
//Get the screen coordinates of the mouse down event
ESRI.ArcGIS.Geometry.IPoint mousePoint = new ESRI.ArcGIS.Geometry.Point();
mousePoint.X = arg.X;
mousePoint.Y = arg.Y;
//Get the map coordinate of the event
ESRI.ArcGIS.Geometry.IPoint mapPoint = new ESRI.ArcGIS.Geometry.Point();
mapPoint = GetMapCoordinatesFromScreenCoordinates(mousePoint, activeView);
//MessageBox.Show(mapPoint.X.ToString() + " " + mapPoint.Y.ToString());
//Transform the coordinate to a GCS
ESRI.ArcGIS.Geometry.IGeometry geometry = mapPoint;
ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3 srf3 = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass();
ESRI.ArcGIS.Geometry.GeographicCoordinateSystem gcs = (ESRI.ArcGIS.Geometry.GeographicCoordinateSystem)srf3.CreateGeographicCoordinateSystem((int)ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_NAD1983);
ESRI.ArcGIS.Geometry.ISpatialReference3 spatialRef3 = (ESRI.ArcGIS.Geometry.ISpatialReference3)gcs;
spatialRef3.SetFalseOriginAndUnits(-180, -90, 1000000);
geometry.Project(spatialRef3);
//Show in web browser
string streetViewLink = @"http://maps.google.ca/maps?q=" + mapPoint.Y.ToString() + "," + mapPoint.X.ToString() + "&num1&s11=" + mapPoint.Y.ToString() + "," + mapPoint.X.ToString() + "&sspn=16.71875,56.536561&ie=UTF8&ll=" + mapPoint.Y.ToString() + "," + mapPoint.X.ToString() + "&spn=0.020401,0.028753&z=15&layer=c&cbll=" + mapPoint.Y.ToString() + "," + mapPoint.X.ToString() + "&panoid=&cbp=12,161.92,,0,5";
System.Diagnostics.Process.Start(streetViewLink);
}
//Get the Map coordinate using the mouse coordinate
public ESRI.ArcGIS.Geometry.IPoint GetMapCoordinatesFromScreenCoordinates(ESRI.ArcGIS.Geometry.IPoint screenPoint, ESRI.ArcGIS.Carto.IActiveView activeView)
{
if (screenPoint == null || screenPoint.IsEmpty || activeView == null)
{
return null;
}
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation =
screenDisplay.DisplayTransformation;
return displayTransformation.ToMapPoint((System.Int32)screenPoint.X, (System.Int32)screenPoint.Y);
}
}
}