Ich arbeite mit vielen Kunden, die die Möglichkeit anfragen, ihre Feature Service Anhänge im Popup der Web Map anstelle eines Hyperlinks anzuzeigen. Das angehängte Skript konvertiert die URL der Feature Service Anhänge in ein Feld. Sie können dann den Anhang nach einiger Konfiguration direkt im Popup anzeigen.<\/P>
<\/P>
Hier ist ein Screenshot, wie Anhänge standardmäßig innerhalb eines Web Map Popups angezeigt werden:<\/P>
Unten sind die Schritte aufgeführt, um das angehängte Bild direkt im Popup anzuzeigen:<\/P>
1. Fügen Sie ein TEXT\/STRING-Feld hinzu<\/A> (z. B. "Picture<\/STRONG>") zum Feature Service hinzu, das eine große Anzahl von Zeichen unterstützen kann (z. B. 1.000).<\/P>2. Führen Sie das angehängte GP-Tool aus.<\/P>3. Konfigurieren Sie das Popup, um Bilder anzeigen<\/A>. Beispiel:<\/P> <\/P><\/P> <\/P>Das Bild wird nun direkt im Popup angezeigt. Beispiel:<\/P> <\/P><\/P> <\/P>Hinweise: <\/STRONG><\/P>Die Timeout-Dauer für einen ArcGIS Online Feature Service ist auf maximal 15 Tage eingestellt.<\/LI>Die Timeout-Dauer für einen ArcGIS Server Service ist auf die Standardeinstellung 'Lifespan of long lived token' gesetzt. Der Standardwert beträgt 1 Tag. Dies kann geändert werden, indem Sie zu Server Manager > Security > Settings gehen. Nach der Aktualisierung des long lived token können Sie den Ablaufparameter in Zeile 33 aktualisieren.<\/LI>Da das Token abläuft, können Sie die Parameter im Skript aktualisieren, sodass dies mit dem Windows Task Scheduler<\/A> ausgeführt werden kann. Hier ist ein Beispiel, wie die Parameter konfiguriert werden:<\/LI><\/UL><\/P> <\/P>Ein Video des Workflows finden Sie unten:<\/P>https:\/\/www.youtube.com/watch?v=WpLJBZ9gnuw<\/A><\/P>
Das Bild wird nun direkt im Popup angezeigt. Beispiel:<\/P>
Hinweise: <\/STRONG><\/P>Die Timeout-Dauer für einen ArcGIS Online Feature Service ist auf maximal 15 Tage eingestellt.<\/LI>Die Timeout-Dauer für einen ArcGIS Server Service ist auf die Standardeinstellung 'Lifespan of long lived token' gesetzt. Der Standardwert beträgt 1 Tag. Dies kann geändert werden, indem Sie zu Server Manager > Security > Settings gehen. Nach der Aktualisierung des long lived token können Sie den Ablaufparameter in Zeile 33 aktualisieren.<\/LI>Da das Token abläuft, können Sie die Parameter im Skript aktualisieren, sodass dies mit dem
Ein Video des Workflows finden Sie unten:<\/P>
would i just write is as 'where':'photo' or do i need to write it a differnet way and say keywords: photo.
Im really new to coding and using python and could use the help.
thanks
@MarkGambordella, yes you can update the where statement on line 87:
is there a way to write the script to query by kewords and only create URL for those with that keyword? I have a signature and a photo column in the attribute table, which have keywords of 'photo' and 'sign'. Can i filter or query or only build an URL for the 'photo' keyword attachments.
@JakeSkinner Great information, thank you Jake!
@DickieRigdon
1. Yes, you can run this script in ArcGIS Notebook. You would need to hardcode the values for the # Variables section in the script
2. If you create an Experience Builder app, you do not need to execute this tool as it will automatically read the attachments
3. If you create an Dashboard, you do not need to execute this tool as it will automatically read the attachments
@JakeSkinner Hi Jake, meeting some resistance on running the Task Scheduler on the organizational level so I would like to ask you about some alternative workflows.
a) Can the Task Scheduler for the toolbox be run in an ArcGIS Notebook instead?
b) Or, if I created my web map app in Experience Builder, would it require the toolbox/task scheduler workflow as well?
c) Lastly, if I used a new Map Viewer map with its automatic photo display and then used that map inside a Dashboard App, would the photos always display after publishing without having to run any refresh scheduling?
I love my current web map app with its widgets and your popup workflow but I may be forced to employ one of these other workflows if they are viable. Thank you for your time.
Copying my answer from the same SO post that brought me here.
If your layer is hosted in AGOL, you can now use the map viewer beta and select the gallery option for attachments under configure pop-up.
This option is currently disabled for enterprise/portal hosted layers. An ideal workaround is to create a web app with the attachment viewer template.
If you're on an older version of enterprise (as we are) there is a bug where an attachment viewer app doesn't honour image orientation. The workaround I've developed, which may be useful to others in similar circumstance, is:
Calculate a field (using arcade) including comma-separated attachment IDs:
//calculate the attach IDs field function IDs(f){ return f.ID; } var Attach_ = Attachments($feature); var AttachIDs = Map(Attach_, IDs); return Concatenate(AttachIDs,',');
This must be a field CALCULATE as attribute expressions do not currently support the Attachments function. I believe an attribute rule may also work.
Once the above is available, you can add attribute expressions in your pop-up (1 per attached image) as:
//build the URL for image attachment <ImageNumber> var ImageNumber = 0 var AttachIDs = split($feature.AttachmentIDs,',') if(ImageNumber > count(AttachIDs) - 1) return '' var AttachID = AttachIDs[ImageNumber] var BaseURL = "<your_domain>/server/rest/services/Hosted/LayerName/FeatureServer/0/" var ObjectID = $feature.OBJECTID return BaseURL + ObjectID + "/attachments/" + AttachID
ImageNumber must be incremented for each expression, starting from 0.
After that you can add an image per attachment as pop-up media, referencing the matching attribute expression for the url and link fields.
@DickieRigdon no, unfortunately there will not be. The two-factor authentication requires another interaction from the end user (i.e. accessing Google Authenticator).
@JakeSkinner Yes, the two factor authentication was the issue. I disabled it and the tool ran perfectly. Would there be a way to write the tool to work with 2-factor? We are going to 2-factor for all our accounts. I'm looking to publish an App using your tool and Windows Task Scheduler to always keep the photos visible. Thanks for your help Jake.
@DickieRigdon I did execute the tool yesterday, so that's why you may be seeing the Picture field updated with the URL.
The two factor authentication could be causing the issue. I would try temporarily disabling it and see if the tool works successfully.
@JakeSkinner
Strange. Even though it was giving me the line 34 error and quit running, my photos populated in the app. I recently setup two factor authentication on my AGOL/ArcGIS Pro accounts. Could that be causing an issue with the tool not running properly?
@JakeSkinner Yes, I'm using that user name. I think I've somehow lost connection between AGOL and Pro for the layer.
lost connection?
@DickieRigdon line 34 is attempting to generate a token, so I believe it's something with your username/password. Are you using the following username, DRigdon_cadoc?
The tool worked for me successfully:
Hi @JakeSkinner
Returned to my web map app with the popup photos after a short hiatus today. I reran the Pro tool to refresh the photos but got the Line 34 error. I had earlier changed the alias to the Picture field name as Full Size Image so that would display in the Pop Up menu. I tried running the tool with both names but no luck. I also deleted the Picture field and recreated it. Editing is enabled and attachments are enabled. I also made sure to use upper/lower case in login. So far nothing is working. I just sent you an invitation to share the layer. Could you take a look?
Thanks, Dickie
Hi Jake, thanks for being so responsive to all of our questions. I have on regarding the image itself not showing-- I saw in a previous comment that it was due to not being a jpeg. However, mine are JPG Files (.jpg) so I am not sure of the problem and thought I would ask. At some points it shows this and sometimes it's just blank. Thank you!
EDIT: somehow they were still coming through as .HEIC photos...I just manually removed everything and added the jpegs in manually. Not a great solution for others unfortunately
@JakeSkinner Great, thanks Jake!
@DickieRigdon yes, as the dataset grows, the field you created to store the URL will update each time the script is executed.
@JakeSkinner Hi Jake, the workflow is working great with the manual token refresh and I'm going to see if the organization can run the Task Scheduler as well. One question, if new records are added to the ArcGIS Pro dataset, will my same toolbox work with the updated data? The dataset will constantly grow in entries every month. I'm building a web map app that will publish the data.
@JakeSkinner Success! That was it. I was using all lower case in toolbox username. Funny, I can login though to AGOL using all lower case.
I'll work to complete the rest of your workflow now.
Thank you Jake!
@DickieRigdon check your username. It is case sensitive. For example, if I try jskinner_countysandbox, I receive the same error. However, jskinner_CountySandbox works.
Tried it again, same error.
@DickieRigdon,
The tool is working from me on my end. Can you send a screen shot of how you have the GP tool configured?
@JakeSkinner invitation sent. Thanks
@DickieRigdon if the service is an AGOL hosted feature service, can you share the service to a group and invite my user account (jskinner_CountySandbox)? I can take a look to see what's going on.
Hi @JakeSkinner ,
Hope you're still following this thread. I'm getting the same error for line 34 as @TimSolomonson and @SamanthaGriffore. I do have "Editing" enabled on my layer. I used /0 in my url as that is what my layer has. Thanks for any tips. -Dickie
@GISREAL below is a video that walks through the workflow:
https://www.youtube.com/watch?v=WpLJBZ9gnuw
Hello. Can you suggest a page where I can learn to do this? I am really a newbie when it comes to script. Thanks in advance!
@Anonymous Useryes, if you overwrite the layer the field that contains the URL will most likely be blank, so you will have to re-execute the tool to populate it.
Hi Jake,
what If we overwrite the feature layer? should we setup this again in the web map?
@MatthewWithumI haven't tested a PDF, but it should work the same as a JPG.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registrieren Sie ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.