Select to view content in your preferred language

How to display a specific entity on a map based on selection?

244
0
04-22-2024 05:22 AM
mikaël
Frequent Contributor

I have this question in my form which pulls up nearby polylines (street sections) based on the location (geopoint) of the user. These polylines are in an AGOL layer. Then the user selects the exact polylines that he is working on based on other attributes (street address).

At this point, with the help of a pulldata("@layer", "getRecord", ...), I know exactly which street section will be worked on and this works fine. I would like to show the polyline on a map.

So I query the json retrieved from the previous pulldata(), like so pulldata("@json", ${field_json}, "geometry"), I get: [objet Object]. If I wrap my function within string(), I get: {"paths": [[[lon1,lat1],[lon2,lat2],[lon3,lat3]]]}.

Finally the function to get the coordinates in text is pulldata("@json", ${field_json}, "geometry.paths") (wrapped with string() or not, doesn't seem to make a difference), I get this: "lon1,lat1,lon2,lat2,lon3,lat3".

I know I can show polylines on a map using a geoshape question and setting the coordinates in the default column in a format like this: "lon1 lat1; lon2 lat2; lon3 lat3".

The format of the output coordinates from the pulldata() geometry json and the input coordinates for the geoshape map question is therefore not the same. How can I easily convert {"paths": [[[lon1,lat1],[lon2,lat2],[lon3,lat3]]]} or "lon1,lat1,lon2,lat2,lon3,lat3" to "lon1 lat1; lon2 lat2; lon3 lat3" ?

In other words, how to display a specific entity on a Survey123 map from based on a selection? 🙂

Thanks!

0 Kudos
0 Replies