Select to view content in your preferred language

Set popup in a layer published by code

199
4
a month ago
mody_buchbinder
Occasional Contributor III

I am using standard code (from the examples) with arcpy and python api to publish a layer (by ref) with feature access.

When I load the mapImage into empty webmap the popup (identify) is turned off by default.

I need to turn it on to see the popups.

If I load the same mapImage to Pro  I do see identify without any extra setting.

When I use Pro (without code) to publish a web layer the problem does not exists. The layer have popups on by default.

I found a few examples about how you turn popup on in a WebMap (using get_data) but no example of how to do it for mapImage or feature service.

I can not find any different between the service that was published using code and the one I created in Pro without code.

Anybody know how to set the default popup to "on" in code for service (not WebMap)?

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor

Hi @mody_buchbinder,

Can you provide the code you are using to publish the service?  Also, is this occurring in Portal or ArcGIS Online?

0 Kudos
mody_buchbinder
Occasional Contributor III

The code I use is very similar to the solution here:  https://community.esri.com/t5/python-questions/publish-a-referenced-feature-service-from-arcgis/td-p...

It can be found in many versions in the Pro docs.

I am publishing to a local Portal.

Thanks

0 Kudos
mody_buchbinder
Occasional Contributor III

I did some more testing. I published the same layer from Pro and code.

Then in notebook I have these lines:

from arcgis.gis import GIS
gis = GIS("pro")
idCode = "2f4b3fd237ae44b9af774adbbafa482f"
idPro = "47e920caec774f53a27a59217de07028"
serverCode = gis.content.get(idCode)
serverPro = gis.content.get(idPro)
serverPro.get_data(try_json=True)
#serverCode.get_data(try_json=True)

So this return a json the represent the layer, it has popupElements tag in it.

When I uncomment the last line and try to get the data from the item published by code I get empty json.

I do not see any set_data method (incase I will create the json myself.

Any idea?

0 Kudos
mody_buchbinder
Occasional Contributor III

I found the solution

There is a way to save the properties into the target service

 

import json
serverData = serverPro.get_data(try_json=True)
item_properties = {"text": json.dumps(serverData)}
serverCode.update(item_properties=item_properties)

Now I have to build this json (since I cannot get it from a service published from Pro) but this is simple task

 

0 Kudos