using System; using System.Collections.Generic; using System.Text; using System.IO; namespace ArcMapAddin1 { public class HyperlinkIStreet : ESRI.ArcGIS.Desktop.AddIns.Tool { public HyperlinkIStreet() { } protected override void OnUpdate() { } //private const string USER_PROMPT_3 = "Are you sure you want to hyperlink to IStreetView?"; private const string CAPTION_3 = "Hyperlink to IStreet"; protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { //var result = System.Windows.Forms.MessageBox.Show(USER_PROMPT_3, CAPTION_3, // System.Windows.Forms.MessageBoxButtons.YesNo, // System.Windows.Forms.MessageBoxIcon.Question); //if (result == System.Windows.Forms.DialogResult.Yes) { //Get coordinates from MouseEventArgs ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = ArcMap.Document; ESRI.ArcGIS.Carto.IActiveView activeView = mxDoc.FocusMap as ESRI.ArcGIS.Carto.IActiveView; ESRI.ArcGIS.Geometry.IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as ESRI.ArcGIS.Geometry.IPoint; //Open IStreetView in default browser System.Diagnostics.Process.Start("http://maps.google.com/maps?q=&layer=c&cbll=" + point.X + "," + point.Y + "&cbp=12,100,0,0,0&output=svembed&t=m&z=17"); } } } }
Solved! Go to Solution.
ESRI.ArcGIS.Geometry.IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as ESRI.ArcGIS.Geometry.IPoint; //project pt to WGS84 System.Type factoryType = null; factoryType = System.Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); ESRI.ArcGIS.Geometry.ISpatialReferenceFactory srFact = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass(); ESRI.ArcGIS.Geometry.IGeographicCoordinateSystem srWGS84 = srFact.CreateGeographicCoordinateSystem(4326); point.Project(srWGS84); //Open IStreetView in default browser System.Diagnostics.Process.Start("http://maps.google.com/maps?q=&layer=c&cbll=" + point.X + "," + point.Y + "&cbp=12,100,0,0,0&output=svembed&t=m&z=17");
Type factoryType = null;
factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
ISpatialReferenceFactory srFact = (ISpatialReferenceFactory)Activator.CreateInstance(factoryType);
IGeographicCoordinateSystem srWGS84 = srFact.CreateGeographicCoordinateSystem(4326);
point.Project(srWGS84);
something like this should do the trick -Type factoryType = null; factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); ISpatialReferenceFactory srFact = (ISpatialReferenceFactory)Activator.CreateInstance(factoryType); IGeographicCoordinateSystem srWGS84 = srFact.CreateGeographicCoordinateSystem(4326); point.Project(srWGS84);
ESRI.ArcGIS.Geometry.IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as ESRI.ArcGIS.Geometry.IPoint; //project pt to WGS84 System.Type factoryType = null; factoryType = System.Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); ESRI.ArcGIS.Geometry.ISpatialReferenceFactory srFact = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass(); ESRI.ArcGIS.Geometry.IGeographicCoordinateSystem srWGS84 = srFact.CreateGeographicCoordinateSystem(4326); point.Project(srWGS84); //Open IStreetView in default browser System.Diagnostics.Process.Start("http://maps.google.com/maps?q=&layer=c&cbll=" + point.X + "," + point.Y + "&cbp=12,100,0,0,0&output=svembed&t=m&z=17"); using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace StreetViewAddin_Camarillo
{
public class StreetViewHyperlink : ESRI.ArcGIS.Desktop.AddIns.Tool
{
public StreetViewHyperlink()
{
}
protected override void OnUpdate()
{
}
//private const string USER_PROMPT_3 = "Are you sure you want to hyperlink to IStreetView?";
private const string CAPTION_3 = "Hyperlink to IStreet";
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
{
//var result = System.Windows.Forms.MessageBox.Show(USER_PROMPT_3, CAPTION_3,
// System.Windows.Forms.MessageBoxButtons.YesNo,
// System.Windows.Forms.MessageBoxIcon.Question);
//if (result == System.Windows.Forms.DialogResult.Yes)
{
//Get coordinates from MouseEventArgs
ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = ArcMap.Document;
ESRI.ArcGIS.Carto.IActiveView activeView = mxDoc.FocusMap as ESRI.ArcGIS.Carto.IActiveView;
ESRI.ArcGIS.Geometry.IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.Y, arg.X) as ESRI.ArcGIS.Geometry.IPoint;
//project pt to WGS84
System.Type factoryType = null;
factoryType = System.Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
ESRI.ArcGIS.Geometry.ISpatialReferenceFactory srFact = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment();
ESRI.ArcGIS.Geometry.IGeographicCoordinateSystem srWGS84 = srFact.CreateGeographicCoordinateSystem(4326);
point.Project(srWGS84);
//Open IStreetView in default browser
System.Diagnostics.Process.Start("http://maps.google.com/maps?q=&layer=c&cbll="
+ point.Y + "," + point.X + "&cbp=12,100,0,0,0&output=svembed&t=m&z=17");
}
}
}
}