Working on developing an ESRI map prototype using Angular4, I have successfully utilized the Draw
tool to initiate a Query
on a FeatureLayer
to draw various graphics such as ConvexHull
and Buffer
.
The primary goal was to create a clear Buffer
graphic over a ConvexHull
graphic (referred to as BufferOfPoints
).
Now, my focus shifts towards generating a Buffer
graphic by combining two or more of the previous Buffers
.
The challenge lies in querying the Buffer graphics from a non-"Queryable" GraphicsLayer
, unlike the points' FeatureLayer
which is queryable.
Frustrated by this limitation, I seek a straightforward solution. Is there one available?
Below is code for the functioning simple scenario as well as the one posing difficulty:
Functioning Scenario (simplified)
// Obtain the Toolbar instance
this.drawToolbar.on('draw-complete', (RectangularSelectorGeometry) => {
this.drawToolbar.deactivate();
// Instantiate the Query
const query = new Query();
query.geometry = RectangularSelectorGeometry.geometry;
// Handle actions for each configured layer
featureLayersConcerned.forEach(featureLayer => {
featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, (features) => {
// Retrieve selected graphic points
const points = features.map((feature) => {
return feature.geometry;
});
...
// Calculate Convex Hull geometry
// Create BufferParameters
// Apply buffer on ConvexHullResult
// Display buffer result
});
});
});
Challenging Scenario (simplified)
// Obtain the Toolbar instance
this.drawToolbar2.on('draw-complete', (RectangularSelectorGeometry) => {
this.drawToolbar2.deactivate();
// Instantiate the Query
const query = new Query();
query.geometry = RectangularSelectorGeometry.geometry;
// Check Graphic layer's existence or create it
let graphicLayer = this.map.getLayer('bufferGraphics');
if (!graphicLayer) {
graphicLayer = new GraphicsLayer({ id: 'bufferGraphics' });
this.map.addLayer(graphicLayer);
}
graphicLayer.selectFeatures(query, GraphicsLayer.SELECTION_NEW, (features) => { // <== Doesn't work :/
...
// Calculate Convex Hull geometry
// Create BufferParameters
// Apply buffer on ConvexHullResult
// Display buffer result
});
});
Refer to this link for better understanding:
In this link, choose a simple graphic and buffer it - resembling the BufferOfPoints
mentioned earlier. My current objective is to query two of those red areas and generate a new Buffer with them.
Hoping this explanation is sufficiently clear.