Skip navigation
All Places > GIS > Web GIS > ArcGIS Online > Blog > 2019 > March
2019

In ArcGIS Online, you can store images as attachments with feature layers. By default, the attachment is shown in the pop-up as a hyperlink. With just a few lines of Arcade Expressions, you can configure the pop-up to display the actual image without requiring your viewers to click on the link.

 

With the March 2019 release of ArcGIS Online, you can now upload geotagged photos to create a point feature layer of each image's location. This blog will outline the process to create the layer and display your geotagged photos in the pop-up. Here is a video showing how to add photos and edit the pop-up (step-by-step instructions are found below):

 

 

After uploading your images, the pop-up includes a hyperlink that looks something like this:

This image shows the default pop-up with a hyperlink to the image attachment.

 

This pop-up configuration workflow will result in the photo displaying in a pop-up like the image below:

This image shows a custom pop-up with a photo of pink flowers found on the trail.

 

To achieve this workflow, there are two steps to the process:

  1. Calculate the attachment ID for each feature
  2. Configure the pop-up to display the attachment URL as an image

 

Steps to view attachments as photos in your web map pop-up:

Part 1:  Calculate the attachment ID   

Note: Sometimes this is not required if the attachment IDs match the feature IDs. There are some cases where these may match, but in most cases these IDs will be different if the data is edited after publishing or in cases where attachments are added after publication (like inspection data when using Collector). 

 

1. Upload your geotagged images to ArcGIS Online as a feature layer. Click here to download a sample zipped folder of images.

2. Make sure your layer is shared with the public.

3. Open the layer in a web map and save the web map.

3. Open the layer table and add a CountAttachments field and calculate it with the Arcade Expression:
      Count(Attachments($feature))

4. Filter the layer to show:

      CountAttachments is greater than 0
5. Add a new field called AttachID and calculate it with the Arcade Expression: 
      First(Attachments($feature)).ID
6. Remove the filter.

 

Part 2:  Create the Pop-up   

1. Click on a point in the map to view the pop-up, and open the hyperlink.

2. Return to the previous tab that shows your web map. Select More Options (the three dots under your layer name in the Content tab), then click Configure Pop-up.

3. Under Attribute Expressions, click the ADD button. 

4. In the Expression builder window, fill in the following logic seen below with the text from your hyperlink URL. The Arcade Expression builds an on-the-fly image URL for each record in your layer using the unique Object ID and attachment ID (calculated in Part 1). 

Note: This is an example of what an image attachment URL looks like: https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/JoshuaTreeHike/FeatureServer/0/7/attachments/7. The first 7 in red is the Object ID and the second 7 in blue is the attachment ID

      var Part1 =       "https://services.arcgis.com/5uh3wwYLNzBuU0Eu/arcgis/rest/services/JoshuaTreeHike/FeatureServer/0/"
      var ObjectID = $feature.OBJECTID
      var Part2 = "/attachments/"
      var AttachID = $feature.AttachID
      When($feature.CountAttachments > 0, Part1 + ObjectID + Part2 + AttachID, null)

 

 

5. Under Pop-up Media, click ADD then choose Image. Edit or remove the title and caption. Under URL, click on the plus sign and select your Arcade Expression. After you add it, it will look something like {expression/expr0}. Additionally, you can edit the pop-up title and additional pop-up content. You can also uncheck the "Show feature attachments as links". 

 

Click here to view a web map example of this in action.

This image shows a web map with a custom pop-up displaying a photo of pink flowers found on the trail.

 

This is a similar workflow to the popular tool and blog written by Jake Skinner.

 

This workflow will get you up and running to display images in URLs in most places but does have some limitations to be aware of:

  • Calculate field is not dynamic. When new features are added, you will need to re-run the field calculation in Part 1.
  • The field calculation only takes the first attachment listed, so displaying multiple images in a single pop-up isn't supported through this workflow.
  • The layer needs to be public to access attachments.

 

We are sharing this workflow to help you display your images in pop-ups as quickly as possible with Arcade, but want you to know that there is more to come. In future releases, we are working to make it easier to display attachments as images. You can see a sneak preview of this work in the 4X JS API. Check out the pop-ups in the Media Map template to see this implementation in a configurable app where it isn't required to do additional configuration to display these images.

 

Stay tuned for more updates and share and discuss your examples and improvements to this code.

KGerrow-esristaff

Generate a Token

Posted by KGerrow-esristaff Employee Mar 16, 2019

In order to access the history log, an administrator token must be appended to your request. You can obtain a token in a few ways. The following log includes two quick ways to grab this token. 

Note. As these are administrative tokens, please don't share your token in the forums. These can potentially be used in malicious ways if the wrong person obtains your token. 

Option 1: Generate a token using postman

1. Download or open postman  (It's free)

2. Click the +New button to create a new request

3. In the new tab, set the following:

4. Click on Body and add the following parameters as Key/Value pairs:

  • username: Your administrator username (case sensitive)
  • password: Your password
  • referer https://www.arcgis.com
  •   f : json

5. Click Send and copy the token in the response below for use in requests

Option 2: Use Developer tools

1. Open developer tools in your browser  ( In chrome, Menu>more tools> Developer tools)

2. Sign into arcgis.com with your administrator credentials

3.  In the developer tools click on network and type 'self' into the filter box

4. Click on the first url, click header tab and scroll to Query String Parameters(the very last section).

5. Copy the token value to use in requests

The History endpoint of the REST API is a great tool to dig into information about events occurring in your organization. Although you easily download a comprehensive CSV of events as an administrator in ArcGIS Online, the REST API, provides the option to customize the data returned and to ask more specific questions. For an example of how to use the history CSV, check out this blog: https://www.esri.com/arcgis-blog/products/arcgis-/administration/exploring-the-organization-activity-log-csv 

 

For this blog I am going to outline the query and results about a specific member of my ArcGIS Online organization.

 

Scenario: It’s time for Karate_Kelly’s year end review. She wants to prove to her boss that she has been busy creating and managing content in the organization. Using the History API, She’ll query all of the events that she has initiated in 2018.

 

Detective Steps:

  1. Formulate the Query

Url: https:/webapps.maps.arcgis.com/sharing/rest/portals/self/history?

Parameters:

all=true – returns events for all members in the organization

start=0 – Starts at the first record

num=10000 – largest amount of events returned (requires csv format)

f=csv – Returns result in a csv

sortOrder=asc – information output in ascending order

token = “6hVsODGfBpk5X_hGc0MOrnxmddIk4bL4hP8FyOAxM0QxL3VEw86iTdB” – admin token required

fromDate =2018-01-01 – start of date range

actors= Karate_KElly – events to be returned (Note, usernames are case sensitive, so if you hit a key by accident while creating your username, check the casing just to be sure... #Karate_KEllyIsNotAMistake)

 

Sample Url constructed:

https://webapps.maps.arcgis.com/sharing/rest/portals/self/history?all=true&start=0&actors=Karate_KElly&sortOrder=asc&fromDate=2018-01-01&num=10000&f=csv&token=Qian2inO2Cqf0tsljaLVJC5YbmjpQvg-CQ565QE75vesENzX5Yorf40K4ai_7fHn8

  1. Submit the request and view the resulting CSV
  2. Perform analysis or use pivot tables to provide insight into actions

 

ActionCount of Actions
Add412
Add Users7
Create12
Delete104
Failed Login15
Login192
Remove Users1
Share252
Update1448

 

Tracking my events by Month:

JanFebMarchAprilMayJuneJulyAugSeptOctNovDec
# of Actions10185727427614829149129101261445

Test: When did I go on Summer vacation last year?

 

This is a neat way to look at your actions and your organizations members actions over time.

 

*Note. Only available in ArcGIS Online

 

Generate a Token

The History endpoint of the REST API is a great tool to dig into information about events occurring in your organization. Although you easily download a comprehensive CSV of events as an administrator in ArcGIS Online, the REST API, provides the option to customize the data returned and to ask more specific questions. For an example of how to use the history CSV, check out this blog: https://www.esri.com/arcgis-blog/products/arcgis-/administration/exploring-the-organization-activity-log-csv 

 

For this blog, I am going to explore the needed queries to export information about login events for a specific organization. To use specific parameters with this API currently, the csv format must be used due to: BUG-000120745. This is planned to be addressed in a future release, but the CSV is a great format for large amounts of information.

 

Scenario: Andy the Administrator wants to understand which of his users have logged into ArcGIS Online and from which apps in February 2019. He has a sneaking suspicion that his employee Oreo J. Sampson doesn’t know his password but is afraid to ask for it to be reset as he asks every single day. Andy is going to verify the login information of his organization to verify

 

Detective Steps:

  1. Formulate the query:

Url: https://sampson23.maps.arcgis.com/sharing/rest/portals/self/history?

Parameters:

all=true – returns events for all members in the organization

start=0 – starts at the first record

num=10000 – largest amount of events returned (requires csv format)

f=csv – returns result in a csv

sortOrder=asc – information output in ascending order

token = “6hVsODGfBpk5X_hGc0MOrnxmddIk4bL4hP8FyOAxM0QxL3VEw86iTdB” – admin token required

fromDate =2019-02-01 – start of date range

toDate=2019-02-28 – end of date range

actions= failedlogin – events to be returned

 

Sample Url constructed:

https://sampson23.maps.arcgis.com/sharing/rest/portals/self/history?all=true&start=0&actions=failedLogin&sortOrder=asc&toDate=2019-02-28&fromDate=2019-02-01&num=10000&f=csv&token=<token>

  1. Submit the request and view the resulting CSV (Failed Login)

Note that some fields have been changed to anonymize data for publication)

 

 

  1. After inspecting the CSV, you can notice that Oreo failed to login on February 1st and didn’t fail again.

 

  1. To find out if Oreo ever successfully logged in, just add login to the actions parameter to receive failed login and login events:

https://sampson23.maps.arcgis.com/sharing/rest/portals/self/history?all=true&start=0&actions=failedlogin,login&sortOrder=asc&toDate=2019-02-28&fromDate=2019-02-01&num=10000&f=csv&token=<token>

 

Reading the output of the resulting CSV, I can see that Oreo eventually logged into ArcGIS Online using ArcGIS Online and ArcGIS Desktop.

 

With these results, Andy can understand who has been logging into the organization, successfully, unsuccessfully and from which app.

 

A note about login actions:

A login action is recorded everytime a successful call is made to the oath2 or generate token login. If you click “Keep me signed in” on the ArcGIS login form then the token will be valid for 2 weeks; the /signin endpoint will not be called and no record will be added to the history log.

 

*Note. Only available with ArcGIS Online

 

Generate a Token

On the evening of March 19, we plan to update ArcGIS Online. Here are five new capabilities to anticipate:

 

  • Encourage viewers to explore your data using the upcoming Interactive Legend configurable app. This app enables viewers to not only read the legend but also touch the data. Giving viewers the opportunity to turn layers on and off, highlight, and filter data through the map legend helps them recognize what is occurring in the map.

Interactive Legend Configurable App

 

  • When searching for items, you will notice a new location filter. Specify a place or region of interest and see only items for that location. This filter works by referencing map extents (geographic boundaries for items). Also, item search will be more efficient and flexible. For example, suggested and partial word searches will be supported for titles.

New Location Filter

 

  • Bring your own or publicly shared maps, layers, or apps together using the upcoming Category Gallery configurable app. This app is an excellent way to organize your items into categories and allow viewers to interact with your items. The categories give viewers the flexibility to filter and find relevant items.

Category Gallery Configurable App

 

  • You will be able to create feature layers from photos that contain location data. Simply upload a file of JPEG photos with geotags and publish as a hosted feature layer. Use the layer in your maps and apps.

 

  • Group owners and managers will be able to help users quickly find what they are looking for by specifying the type of items (such as apps or maps) that display by default on the group's content and overview tabs.

 

Please note that all planned updates are subject to change. A comprehensive list of implemented changes will be provided in our What's New email, blog, and documentation. Visit the ArcGIS blog to learn more about what's coming and new.

 

Sign up to receive What's New emails