0

I would like to delete the last 10 letters of a URL to use in ArcGIS online to show photos in the popup. Any suggestions? I have seen people put JavaScript in the image configuration settings to get the photos to show in Show attached images inside popup with ArcGIS Online?. Maybe deleting part of a URL is possible too.

  • Hi - could you please be a bit more specific about "delete the last 10 letters of a URL"? Maybe an example of what URL you have, and how you need it to be modified for each feature in the popup? – GavinR Dec 25 '17 at 19:36
  • I am using someone else's layer in my webmap: dot.ca.gov/hq/env/gis/stormwater/sdsi/d7/photos/dp/… if I remove the last 10 characters so it reads: dot.ca.gov/hq/env/gis/stormwater/sdsi/d7/photos/dp/…. Then I can add 1.jpg so its reads: dot.ca.gov/hq/env/gis/stormwater/sdsi/d7/photos/dp/… I wanted to do this using a script within the configure pop/add photo section of arcgis online – brandon p Dec 27 '17 at 23:16
  • I assume "1" would be the ID attribute of the feature? So you if someone clicks on feature with ID 1, it would be dp/110_s_22_12966_dis_34_0358_118_2749/1.jpg, and if the clicked on feature with ID 2 it would be dp/110_s_22_12966_dis_34_0358_118_2749/2.jpg and so on? – GavinR Dec 30 '17 at 15:20
1

You can use Arcade expressions to do this. In ArcGIS Online, select the layer > Configure Popup and below the Pop-up Content area add a new Attribute Expression.

var orig = "http://www.dot.ca.gov/hq/env/gis/stormwater/sdsi/d7/photos/dp/110_s_22_12966_dis_34_0358_118_2749/index.html"
var origSplit = Split(orig, "index.html",1) 
var id = $feature.objectid
var new = Concatenate([origSplit[0],id,".jpg"])
return new  

Select Test and look at the returned result. Select OK and then in the Pop-Up Content, you have the option to show the results of the query in the popup window. This solution means that you are doing all the calculations dynamically which is nice because then you don't have to edit data from the original layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.