Hello create query feature layer
I run a query by creating a query feature layer.
But it returns a single value.
My codes are as follows.
How can I fetch all data with the same values using forEach?
This might be what you're trying to do:
let featureName = document.getElementById("searchInput").value;
let query = layer.createQuery();
query.where = "adi_soyadi = '" + featureName + "'";
query.outFields = ["*"];
query.returnGeometry = true;
layer.queryFeatures(query).then(function(featureSet) {
featureSet.features.forEach(function(feature) {
//do something
});
});
How can I return the query result?
I want to show the values coming with foreach
You access the values via the attributes property. For example:
let featureName = document.getElementById("searchInput").value;
let query = layer.createQuery();
query.where = "adi_soyadi = '" + featureName + "'";
query.outFields = ["*"];
query.returnGeometry = true;
layer.queryFeatures(query).then(function(featureSet) {
featureSet.features.forEach(function(feature, index) {
var fieldNames = Object.keys(feature.attributes);
fieldNames.forEach(function(fieldName) {
console.info("Result " + index.toString() + ": " + fieldName + " = " + feature.attributes[fieldName]);
});
});
});
I got the query result I wanted from the layer and used the returned values as I wanted.
I want to run the same query in 2 different layers. and I want to show the results on the map
For my code to run, the button is clicked and the data I want to query for the second query appears.
The query operation is expected to occur, but it does not happen.
Can you show the code that executes when the button is clicked? I assume it is the parkResultClickHandler function.
The park Result Click Handler function allows me to bring the values returned in the query closer to the value I clicked on the list and to open a pop-up window.
Ok, it looks like I asked for the wrong thing. You said you're trying to query two layers, but only seeing results for one. Can you show the code for where you're querying the two layers? I only see code where one layer is being queried.
merhaba@JoelBennett ;
I query in two layers.
How can I show the searched values when entering search data (name/surname), for example "NAil"?
// HTML Kodu
//JS code
I'm sorry, I guess I don't understand the problem, and the code being in a different language adds to the confusion. I'm not sure I can help with this one.