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:
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
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?
You probably want to use pulldata's @layer mode, this post should cover everything you need to know.
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));
});
}