Select to view content in your preferred language

Pulling Geometry from Feature Layer into Forms (S123 Connect)

151
3
2 weeks ago
LiamBirkett
New Contributor

Hi folks

I'm in Survey123 Connect and need to display a geometry from a feature layer in Forms - that reflects a user selected ID 

My current code is this:

LiamBirkett_0-1736520801479.png

I've ensured the feature layer its trying to pull data from sits within the correct webmap in Linked Content but afraid nothing is pulling through

Any help or thoughts hugely appreciated

Many thanks 🙂

*Please note I'd removed the real feature layer URL to fit the code on screen

0 Kudos
3 Replies
abureaux
MVP Frequent Contributor

Have you seen this blog post: Survey123 Tricks of the Trade: Lines and Polygons

Scroll down to Geotrace and geoshape in the Survey123 field app Inbox. I am thinking that is what you are looking for?

0 Kudos
DavidSolari
MVP Regular Contributor

You probably want to use pulldata's @layer mode, this post should cover everything you need to know.

0 Kudos
LiamBirkett
New Contributor

Thanks guys, afraid it may need something more complex as looking to pull through the feature based on a dynamic user-selection ID. I've dabbled with a script to see i that could work, also afraid to no avail 😕

Am I over-complicating this?

// save this as getGeometry.js

function getGeometry(selectedValue) {

var featureLayerUrl = '<URL>';

var query = {

where: "ID='" + selectedValue + "'",

outFields: ['*'],

returnGeometry: true,

f: 'json'

};

return new Promise(function(resolve, reject) {

fetch(featureLayerUrl + '/query?' + new URLSearchParams(query))

.then(response => response.json())

.then(data => {

if (data.features && data.features.length > 0) {

resolve(data.features[0].geometry);

} else {

reject('No features found');

}

})

.catch(error => reject(error));

});

}

0 Kudos