Ik werk met veel klanten die de mogelijkheid willen om hun feature service-bijlagen weer te geven in de web map-popup in plaats van een hyperlink. Het bijgevoegde script zet de URL van de feature services-bijlagen om naar een veld. U kunt de bijlage dan direct in de popup weergeven na enige configuratie.<\/P>
<\/P>
Hier is een screenshot van hoe bijlagen standaard worden weergegeven binnen een web map-popup:<\/P>
Hieronder staan de stappen om de bijgevoegde afbeelding direct in de popup te tonen:<\/P>
1. Voeg een TEKST\/STRING-veld toe<\/A> (bijv. "Picture<\/STRONG>") aan de feature service dat een groot aantal tekens kan ondersteunen (bijv. 1.000).<\/P>2. Voer het bijgevoegde GP-hulpmiddel uit.<\/P>3. Configureer de pop-up om Afbeeldingen weer te geven<\/A>. Bijv:<\/P> <\/P><\/P> <\/P>De afbeelding wordt nu direct in de popup weergegeven. Bijv:<\/P> <\/P><\/P> <\/P>Opmerkingen: <\/STRONG><\/P>de time-out voor een ArcGIS Online feature service is ingesteld op maximaal 15 dagen.<\/LI>de time-out voor een ArcGIS Server-service is ingesteld op de standaard 'Lifespan of long lived token'. De standaard is 1 dag. Dit kan worden gewijzigd via Server Manager > Security > Settings. Nadat het long lived token is bijgewerkt, kunt u de vervaldatumparameter op regel 33 aanpassen.<\/LI>Aangezien het token verloopt, kunt u de parameters in het script aanpassen zodat dit kan worden uitgevoerd met Windows Task Scheduler<\/A>. Hier is een voorbeeld van hoe u de parameters configureert:<\/LI><\/UL><\/P> <\/P>Een video van de workflow vindt u hieronder:<\/P>https:\/\/www.youtube.com\/watch?v=WpLJBZ9gnuw<\/A><\/P>
De afbeelding wordt nu direct in de popup weergegeven. Bijv:<\/P>
Opmerkingen: <\/STRONG><\/P>de time-out voor een ArcGIS Online feature service is ingesteld op maximaal 15 dagen.<\/LI>de time-out voor een ArcGIS Server-service is ingesteld op de standaard 'Lifespan of long lived token'. De standaard is 1 dag. Dit kan worden gewijzigd via Server Manager > Security > Settings. Nadat het long lived token is bijgewerkt, kunt u de vervaldatumparameter op regel 33 aanpassen.<\/LI>Aangezien het token verloopt, kunt u de parameters in het script aanpassen zodat dit kan worden uitgevoerd met
Een video van de workflow vindt u hieronder:<\/P>
Dambé SANWOGOU the pop-ups should be retained for 15 days before you have to execute the tool again. Have you tried configuring the variables in the script and having Windows Task Scheduler run the script (see the example in the document)? You could schedule the script to run nightly and you won't have to worry about the token expiring, which causes the images to no longer display.
Hi Jake Skinner, i have the same problem, after a few days, my image don't display, i use arcgis Online
I figured out I could manually turn of editor tracking on the layer, save, run the script, turn it back on and save again. A little tedious, but it works. Now I just have to remember!
It would be nice to be able to include a "disable" and "re-enable" editor tracking function at the beginning and end of this GP tool. Maybe even allow you to toggle editor tracking off in the user dialog.
Has anyone figured out how to run this script without updating the editor tracking? I'd like to retain the editor username and last edit time stamp of my field collectors. I'm currently using hosted feature services in ArcGIS Online.
Orca Maritime can you share the service to an AGOL Group and invite my user account (jskinner_CountySandbox)?
Jake,
I'm having an error when running the script in Pro. It is saying that my web layer doesn't have attachments, but as you can see on the right-hand side of the image, that it does have attachments.
Check out this additional way to show attachments in a web map pop-up:
https://community.esri.com/community/gis/web-gis/arcgisonline/blog/2019/03/22/show-attachments-in-pop-ups-with-arcade-expressions
Kim Buck unfortunately, you can only display one photo in the pop-up. You will still need to create a feature service from this data. The service needs to be editable in order to run the script. You can create a hosted feature layer view that is not editable, and use this in your web maps/applications.
Thank you Jake. We don't want public users to be able to edit the feature service that we want photos associated with. I am going to add the attachments in ArcMap and then try using your script. We have multiple pictures for each feature, is it possible to display them all in the pop up for one feature?
Kim Buck the easiest way to link a photo with the parcel is using attachments:
For feature classes:
Enabling attachments—ArcGIS Help | ArcGIS for Desktop
Hosted Feature Services:
Manage hosted feature layers—ArcGIS Online Help | ArcGIS
After you have images added as attachments you can execute this tool to show them in the pop-up.
Where do you need to have all the images you want in the pop up hosted? I wanted to have a folder in AGOL with all the photos in one place, would this work? I am unsure how I link each photo to the right parcel, do they need to share a field, same concept as a join?
Thanks, works now
Ian Hamilton if you are using an ArcGIS Online Hosted Feature service, you will generate the token with the following:
<SPAN class="comment token">#generate token for AGOL Hosted Feature Service</SPAN> <SPAN class="keyword token">if</SPAN> hostedFeatureService <SPAN class="operator token">==</SPAN> <SPAN class="string token">'true'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> username <SPAN class="operator token">and</SPAN> password<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> tokenURL <SPAN class="operator token">=</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.arcgis.com%2Fsharing%2Frest%2FgenerateToken" target="_blank">https://www.arcgis.com/sharing/rest/generateToken</A><SPAN>'</SPAN></SPAN> params <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'pjson'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'username'</SPAN><SPAN class="punctuation token">:</SPAN> username<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'password'</SPAN><SPAN class="punctuation token">:</SPAN> password<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'referer'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.arcgis.com" target="_blank">https://www.arcgis.com</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'expiration'</SPAN><SPAN class="punctuation token">:</SPAN> str<SPAN class="punctuation token">(</SPAN><SPAN class="number token">21600</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN> response <SPAN class="operator token">=</SPAN> requests<SPAN class="punctuation token">.</SPAN>post<SPAN class="punctuation token">(</SPAN>tokenURL<SPAN class="punctuation token">,</SPAN> data <SPAN class="operator token">=</SPAN> params<SPAN class="punctuation token">,</SPAN> verify <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN> token <SPAN class="operator token">=</SPAN> response<SPAN class="punctuation token">.</SPAN>json<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> PrintException<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> token <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Hi Jake, I am trying to get your script to run in a toolbox in ArcGIS Pro with a feature service on ArcGIS Online. I am getting a token error. What would be the correct URL to the token generator and also the correct data parameters to the response POST. I would ultimately like to get something based on you example to work in a geoprocessing service in WebApp Builder widget. my service URL is of the form https://services1.arcgis.com/....../arcgis/rest/services/...../0 If I use the code as is I get the following error
SERVER: services1.arcgis.com
tokenURL: http://services1.arcgis.com/arcgis/admin/generateToken
response: <Response [200]>
Error: Line 120 -- "token = response.json()['token']": 'token'
if federatedServer == 'false': if username and password: try: server = baseURL.split("//")[1].split("/")[0] arcpy.AddMessage("SERVER: {0}".format(server)) tokenURL = 'http://' + server + '/arcgis/admin/generateToken' #tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken' arcpy.AddMessage("tokenURL: {0}".format(tokenURL)) params = {'username': username, 'password': password, 'client': 'requestip', 'f': 'pjson', 'expiration': str(1440)}
response = requests.post(tokenURL, data = params, verify = False) token = response.json()['token'] except: PrintException() else: token = ''
Excellent – thank you!
Von: Jake Skinner
Gesendet: Freitag, 22. Februar 2019 20:24
An: Shapiro, Aurelie
Betreff: Re: - Show Attachments in Web Map Popup
GeoNet <https://community.esri.com/?et=watches.email.document_comment>
Show Attachments in Web Map Popup
new comment by Jake Skinner<https://community.esri.com/people/jskinner-esristaff?et=watches.email.document_comment> View all comments on this document<https://community.esri.com/docs/DOC-7445-show-attachments-in-web-map-popup?commentID=70727&et=watches.email.document_comment#comment-70727>
Aurelie Shapiro I would create the field in the survey, then re-publish the survey if possible. Yes, you need to run this each time a survey is submitted. You can set this script up to run using Windows Task Scheduler, so it can execute at a given interval:
Scheduling a Python script or model to run at a prescribed time
Thanks Jake!
I started all over and it worked - I was trying to run it on a feature service view, and not the original service.
The original feature service however is an output from survey123. As we are still collecting data, will the survey still work if I have created new fields online, but aren't in the original survey? Also, I need to re-run the tool for future survey responses?
Best,
-aurélie
Aurelie Shapiro can you share the service to a Group in ArcGIS Online and invite my user account (jskinner_CountySandbox)? I can take a look and see what's going on.
I guess this is really old, but I just ran the script, it says it's successful, but the field I calculated remains empty...
Orca Maritime you need to specify the index value of the layer at the end of the URL (i.e. FeatureServer/0).
I'm getting this error when I'm running the Tool
Troy Wirth you can add a text field (i.e. Picture) with a large size (i.e. 1000) to the survey, and then publish the survey. When running the tool, you can specify this field. I haven't tested, but should work.
Hi Jake Skinner - Thanks again for this great script. I've been using it a lot. I would like to run this directly on a hosted feature service that is connected to a survey123 form. Do you think that would work and would it mess anything up? Thanks and sorry if someone has asked this and I did not see it!
Troy
Thank you, Jake - it was the missing layer number (/0) that was preventing it from working. All is good now!
Thank you Jake. It is working now. I have set the proxy as environmental variable and restarted my PC (in case someone else has similar problem).
Lidia Dudina I believe you are correct that there is a proxy issue. I was able to execute the tool successfully:
Unfortunately, I don't have a proxy to test against. I found the following web page that discusses Proxies with the Requests module. You may just need to add the following:
proxies <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">'http'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F10.10.1.10%3A3128" target="_blank">http://10.10.1.10:3128</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'https'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F10.10.1.10%3A1080" target="_blank">http://10.10.1.10:1080</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
And then update the response line:
response <SPAN class="operator token">=</SPAN> requests<SPAN class="punctuation token">.</SPAN>post<SPAN class="punctuation token">(</SPAN>tokenURL<SPAN class="punctuation token">,</SPAN> data <SPAN class="operator token">=</SPAN> params<SPAN class="punctuation token">,</SPAN> verify <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> proxies<SPAN class="operator token">=</SPAN>proxies<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
For now, the Picture field is updated and you should be able to show attachments in the pop-up for the next 15 days.
Malcolm Williamson you will need to enable Update capabilities for this service since this tool updates a field. Also, make sure you specify the /0 in the feature service URL. After enabling update capabilities, you can set up your tool like below:
Hi Jake Skinner. I've created group with my feature class and added you as a user. The error that I get is:
Max retries exceeded with url: /sharing/rest/generateToken (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',)))
I was thinking maybe I need proxy to be included in the code? It gives the error on line
"response = requests.post(tokenURL, data = params, verify = False)"
Thanks a lot!
Hi Jake,
I just tried the GP tool from both the latest Pro and ArcMap, connecting to a very simple "test" feature service hosted on AGOL. Full edit capabilities, and there are indeed attachments. Yet, when running the tool from either platform, I get a "Feature Service does not contain attachments" error. I've sent you an invitation to join the group that I've shared the feature layer with. Thanks for any insight you can provide!
-Malcolm Williamson
Lidia Dudina if you share your service to an ArcGIS Online Group and invite my user account (jskinner_CountySandbox), I can take a look at it for you.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.