Hello guys! I am trying to plot polygon layers on existing feature layer. Before that I need to get if points exist in a particular geometry after querying the feature layer. Can I also show different color for rings of polygon?
Here is my code below.
const queryNew = myFeatureLayer.createQuery();
queryNew.spatialRelationship = "intersects";
queryNew.returnGeometry = true;
myFeatureLayer.queryFeatures(queryNew).then(function (results) {
const result = results.features.map((data) => data.geometry["rings"][0]);
const poly = new Polygon({
spatialReference: {
wkid: 4283
},
});
slider.on("thumb-drag", function (event) {
const filterForecast = forecast.filter(
(data) =>
data.poaching_risk * 100 > slider.values[0] &&
data.poaching_risk * 100 < slider.values[1]
);
var riskLatlonFilter = (filterForecast as unknown as any[]).map(
(element) => {
return [element.lon, element.lat];
}
);
console.log(riskLatlonFilter);
});
});
Solved! Go to Solution.
It doesn't look like you've set the geometry property of your "queryNew" query object. Set that to be the geometry of the polygon(s) you want to intersect the features in "myFeatureLayer".
It doesn't look like you've set the geometry property of your "queryNew" query object. Set that to be the geometry of the polygon(s) you want to intersect the features in "myFeatureLayer".
Can I change colour for different polygon.
That's a vague question, but generally, Yes. Check out Data-driven styles. Here's a tutorial.
If you want to style based on something else, you could look into making a Graphics Layer and applying the symbology however you want.