ArcMap crashes after using a custom toolbar

521
0
03-06-2019 01:52 PM
GordonD
New Contributor

I attempted to write a custom toolbar similar to this one, but in my version clicking anywhere within a data frame opens a new tab of King County iMap that points to the location you clicked. Here is my code:

import arcpy
import pythonaddins
import webbrowser

class ToolClass(object):
    """Implementation for Open_iMap_addin.tool (Tool)"""
    def __init__(self):
        self.enabled = True
        self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
    def onMouseDownMap(self, x, y, button, shift):
        mxd = arcpy.mapping.MapDocument("CURRENT")
        df = arcpy.mapping.ListDataFrames(mxd)[0]
        point = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(df.spatialReference.PCSCode))
        newPoint = point.projectAs(arcpy.SpatialReference(4326))
        print(x,y)
        print(str(newPoint.centroid.X) + ", " +str(newPoint.centroid.Y))
        webbrowser.open('https://gismaps.kingcounty.gov/iMap/?center='+ str(newPoint.centroid.X) + '%2C' + str(newPoint.centroid.Y) + '&level=19', new=2)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The tool works, but my ArcMap crashes immediately after opening iMap and I get the following error: 

Any idea why this might be happening?

0 Kudos
0 Replies