Layer.fromArcGISServerUrl("").then(function (layer) {
map.add(layer);
view.popup.autoOpenEnabled = false; // <- disable view popup auto open
view.on("click", function (event) { // <- listen to view click event
if (event.button === 0) { // <- check that was left button or touch
view.whenLayerView(layer).then(function (layerView) {
const query = layerView.layer.createQuery();
query.geometry = view.toMap(event);
query.distance = 1;
query.units = "meters";
layerView.queryFeatures(query).then(
response => {
document.getElementById("infomap").innerText = JSON.stringify(response.features);
console.error(response);
},
err => {
document.getElementById("infomap").innerText = "Query returns an error, check console to see what happen!.";
console.error(err);
}
);
});
}
});
});
I want to get info about pop up's using ArcGis in React and I get the mistake that createQuery is not a function. I dont understand why I have this err. Help please
From the documentation, I understand that layer is a base class, and there are multiple types of layers that extend that class. The createQuery method is not on the base class so it might be that you are calling createQuery on layer type that does not have that method implemented.
What does layerView.layer.constructor.name give you in the console?