How to get the point geometry from a pop-up to pass as a URL parameter to Dashboard

865
3
Jump to solution
01-21-2022 04:25 PM
Labels (3)
JoeBryant1
Occasional Contributor II

Hopefully this is an easy one, but I haven't been able to find an answer.

I'm constructing a hyperlink in the pop-up of a point feature in the (new) Map Viewer web map. This hyperlink launches a Dashboard I have constructed. I'd like the Dashboard to zoom to the feature whose pop-up I had open in the web map. I have been testing URL parameters, but the Feature Parameters in my Dashboard settings don't zoom to the features, they just filter the other indicators I have (this might be a separate issue?).

I think I can solve this if I add a geometry point URL parameter. I just don't know the syntax to append the coordinates of the currently selected pop-up point to the end of the URL.

Something like https://company.maps.arcgis.com/apps/dashboards/<ID>#Geo={geometry}, where 'Geo' is the name given to my URL parameter, and '{geometry}' is the coordinate attribute pair I need to pull from the feature and pass to the Dashboard.

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Regular Contributor

Documentation for using URL parameters can be found here: 

Use URL parameters to create and modify maps—ArcGIS Online Help | Documentation

I don't have a Dashboard to test, but it works for a WebApp.

// base url of your Dashboard
// if there's no "?" in the URL, add one at the end, else add "&"
var url = "https://company.maps.arcgis.com/apps/dashboards/123?"
//var url = "https://company.maps.arcgis.com/apps/dashboards/index.html?id=123&"

// get the geometry of your feature
// I'm working with point features, if you have lines/polygons, call Centroid
var geo = Geometry($feature)   // var geo = Centroid($feature)

// option 1: use center and level parameters
// center is formatted as "x,y,wkid"
var level = "level=15"
var center = "&center=" + Concatenate([geo.x, geo.y, geo.spatialReference.wkid], ",")
return url + level + center

// option 2: use extent parameter
// extent is formatted as "min_x,min_y,max_x,max_y,wkid"
var ext_width = 200
var ext_height  =200
var ext = "extent=" + Concatenate([geo.x-ext_width/2, geo.y-ext_height/2, geo.x+ext_width/2, geo.y+ext_height/2, geo.spatialReference.wkid], ",")
return url + ext

 


Have a great day!
Johannes

View solution in original post

0 Kudos
3 Replies
JohannesLindner
MVP Regular Contributor

Documentation for using URL parameters can be found here: 

Use URL parameters to create and modify maps—ArcGIS Online Help | Documentation

I don't have a Dashboard to test, but it works for a WebApp.

// base url of your Dashboard
// if there's no "?" in the URL, add one at the end, else add "&"
var url = "https://company.maps.arcgis.com/apps/dashboards/123?"
//var url = "https://company.maps.arcgis.com/apps/dashboards/index.html?id=123&"

// get the geometry of your feature
// I'm working with point features, if you have lines/polygons, call Centroid
var geo = Geometry($feature)   // var geo = Centroid($feature)

// option 1: use center and level parameters
// center is formatted as "x,y,wkid"
var level = "level=15"
var center = "&center=" + Concatenate([geo.x, geo.y, geo.spatialReference.wkid], ",")
return url + level + center

// option 2: use extent parameter
// extent is formatted as "min_x,min_y,max_x,max_y,wkid"
var ext_width = 200
var ext_height  =200
var ext = "extent=" + Concatenate([geo.x-ext_width/2, geo.y-ext_height/2, geo.x+ext_width/2, geo.y+ext_height/2, geo.spatialReference.wkid], ",")
return url + ext

 


Have a great day!
Johannes
0 Kudos
JohannesLindner
MVP Regular Contributor

Actually, if you use this expression, you can use it for all geometry types:

// base url of your Dashboard
// if there's no "?" in the URL, add one at the end, else add "&"
var url = "https://company.maps.arcgis.com/apps/dashboards/123?"
//var url = "https://company.maps.arcgis.com/apps/dashboards/index.html?id=123&"

// how much do you want to zoom out?
var buffer_dist = 200

// use the extent parameter
var ext = Extent(Buffer($feature, buffer_dist))
var ext_par = "extent=" + Concatenate([ext.xMin, ext.yMin, ext.xMax, ext.yMax, ext.spatialReference.wkid], ",")
return url + ext_par

Have a great day!
Johannes
0 Kudos
JoeBryant1
Occasional Contributor II

Thanks Johannes.

I wasn't sure if the geometry was a global attribute you could call without using Arcade, the same way you can with the field names. Since it sounds like it is not, it makes sense you have to do this in 2 steps. You first have to create an expression that declares the variable ("geo" in your example) and assigns the point coordinate ordered-pair to the expression with the geometry($feature) Arcade expression. You can then use that variable as a URL parameter in your hyperlink string. 

0 Kudos