AnsweredAssumed Answered

Pro AddIn: Click to Open Web Page

Question asked by dylanh0 on May 1, 2019
Latest reply on May 3, 2019 by Matthew.Washburn_TXDOT

I'm still bitter with ESRI for not bringing Python Add-Ins over to Pro.. I have never coded in C#/.NET and know very little about ArcObjects. My Python skills I consider to be strong, not just scripting but app development, so I think I can pick up on the .NET SDK, though I am reluctant to get into this rabbit hole. I have VS and the SDK up and running, went through some tutorials, just looking for some guidance on a specific solution here.


A while back I created a little ArcMap Add-In, just a single toolbar button that will open Google Street View in your default browser when the user clicks a location on the map. I'd like to deploy a button like this in Pro, but after searching and searching for 'C# open a web page on click event' all I was coming up with was ASP.NET stuff and I have zero knowledge on any of this stuff lol! I was basically looking for a one liner to add into the onClick event of my button.cs code to just open to start with.


Below is the Python Add-In code that accomplishes this, and I am not looking for anyone to code this entirely for me, but maybe some suggestions, guidance, resources, etc. All this does is grab the coordinates from where the user clicks and feeds that into a url to open street view.

import arcpy
import pythonaddins
import webbrowser
import threading

class OpenStreetView(object):
    """Implementation for StreetView_addin.tool (Tool)"""
    def __init__(self):
        self.enabled = True
        self.cursor = 3 # cross hair cursor

    def onMouseDownMap(self, x, y, button, shift):
        mxd = arcpy.mapping.MapDocument("CURRENT")
        df = arcpy.mapping.ListDataFrames(mxd)[0]
        sr_df = df.spatialReference
        pt = arcpy.Point(x,y)
        pt_geom = arcpy.PointGeometry(pt, sr_df)
        new_pt_geom = pt_geom.projectAs("WGS 1984")
        new_pt = new_pt_geom.firstPoint
        new_X = new_pt.X
        new_Y = new_pt.Y
##        message = "Projected: " + str(x) + ", " + str(y) + " Geographic: " + str(new_X) + ", " + str(new_Y)
##        pythonaddins.MessageBox(message, "Coordinates")
        maps_url = "" + str(new_Y) + "," + str(new_X)
        threading.Thread(, args=(maps_url,0)).start()