POST
|
I'm trying to use python to create a custom pop-up attribute expression in an ArcGIS Online Web Map, but I'm running into some issues. Here is the python code I am running in an ArcGIS Pro Notebook: import arcgis
#Connect to ArcGIS Online using active portal in ArcGIS Pro
gis = arcgis.gis.GIS("pro")
#Get web map, and create a custom attribute expression
wm_item = gis.content.get("84a22dc69c57437d97292a12f05cf4d7")
wm_object = arcgis.mapping.WebMap(wm_item)
wm_object.layers[0].popupInfo.expressionInfos = [{
"name": "expr1",
"title": "test",
"expression": "'test'",
"returnType": "text"
}]
#Update web map
wm_object.update()
#Check to see if web map updated
wm_object.layers[0].popupInfo.expressionInfos The code appears to be working correctly, as I can see the expression I created when I open the web map's "configure pop-up" settings in a web browser: However, when I click on a feature in the web map, the custom attribute I created is no where to be found: Anyone know how to fix this?
... View more
05-26-2020
02:59 PM
|
1
|
1
|
1205
|
POST
|
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?
... View more
03-06-2019
01:52 PM
|
0
|
0
|
524
|
Title | Kudos | Posted |
---|---|---|
1 | 05-26-2020 02:59 PM |
Online Status |
Offline
|
Date Last Visited |
07-14-2021
05:50 PM
|