I have a geojson url that I am able to see features on the map. I can use a definition query towards it, but I cannot access the values. The data comes in as undefined, though I can see the count of the features. The data comes in as: (36) [u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u] in the console. I'm not sure how to extract the values from a geojson link.
const query = geoJSONLayer.createQuery().set({
outFields: ["Category"],
returnGeometry: true
});
console.log(query)
const { features, fields } = await geoJSONLayer.queryFeatures(query);
console.log(features.attributes)
let sel = document.getElementById("sel").innerHTML = "";
// Populate dropdown with list of provinces
let dropdown = document.getElementById('locality-dropdown');
dropdown.length = 0;
let defaultOption = document.createElement('option');
defaultOption.text = 'Choose State/Province';
dropdown.add(defaultOption);
dropdown.selectedIndex = 0;
const url = mygeojsonurl;
fetch(url)
.then(
function (response) {
if (response.status !== 200) {
console.warn('Looks like there was a problem. Status Code: ' +
response.status);
return;
}
// Examine the text in the response
response.json().then(function (data) {
let option;
let jsonobj = url;
jsonobj.length; i++) {
dropdown.innerHTML = dropdown.innerHTML + '<option value="' + jsonobj[i]['id'] + '">' + jsonobj[i]['Category'] + '</option>'
}
Hi there,
Could you please share your geojson url so that I can take a look at what might be going on? If you cannot share then would you mind sharing json for one feature from your geojson file?
I can repost it in the code if need be. Try this one.
Hi there,
Perhaps I misunderstood your question. GeoJSONLayer.queryFeatures runs successfully and returns attributes of the features as expected as you can see here in this codepen: https://codepen.io/U_B_U/pen/ExRMoGB?editors=1000