Select to view content in your preferred language

See buffer in Query widget?

386
4
Jump to solution
4 weeks ago
ncramer11
Occasional Contributor

I am configuring a Query widget for our users, so that they can select taxlots from a feature layer, and then identify neighboring taxlots with a buffer (Intersect relationship). Is there a setting to make the buffer appear visually on top of the features? If not, perhaps I can submit this as an idea, as being able to visually see the buffer would help with our analysis considerably.

 

The settings I have configured to perform this buffer. It is enabled, but doesn't appear on the map.The settings I have configured to perform this buffer. It is enabled, but doesn't appear on the map.The selected taxlot feature, and its neighbors. The buffer is performing correctly, but I have no way to see it.The selected taxlot feature, and its neighbors. The buffer is performing correctly, but I have no way to see it.

 

 

0 Kudos
2 Solutions

Accepted Solutions
JeffreyThompson2
MVP Frequent Contributor

Yes, you are correct. The Selected Features From A Datasource option in the Query Widget does not show a visual representation of its buffer. There is one with the Drawn Graphic option.

You may consider using Near Me instead. There is a lot of overlap between Near Me and Query and Near Me shows its buffer area.

GIS Developer
City of Arlington, Texas

View solution in original post

ncramer11
Occasional Contributor

Update -- Solved using Developer Edition!

@JeffreyThompson2 you were right that the visual buffer was missing from the "Feature from Data Source" mode. With some help from Claude, I was able to modify the Query widget's source code to add the buffer graphic. I'll try to explain as best I can.

 

The widget has two separate geometry components in src/runtime/:

  • geometry-from-draw.tsx — already creates a buffer graphic on the map
  • geometry-from-ds.tsx — calculates the buffer for the query, but never visualizes it

geometry-from-ds.tsx needs the same buffer infrastructure as the draw component. The challenge is getting access to the map view. The draw component relies on spatialMapWidgetIds being configured, but using only the DS filter may never set that. The solution is MapViewManager, which tracks map views in the app without needing explicit widget configuration:

import { MapViewManager, type JimuMapView } from 'jimu-arcgis'

const ensureBufferLayer = React.useCallback(async (): Promise<boolean> => {
  if (bufferLayerRef.current) return true
  const mvManager = MapViewManager.getInstance()
  const ids = mvManager.getAllJimuMapViewIds()
  if (!ids?.length) return false
  const jimuMapView: JimuMapView = mvManager.getJimuMapViewById(ids[0])
  if (!jimuMapView?.view) return false
  jimuMapViewRef.current = jimuMapView
  const GraphicsLayer = await loadArcGISJSAPIModule('esri/layers/GraphicsLayer')
  bufferLayerRef.current = new GraphicsLayer()
  jimuMapView.view.map.add(bufferLayerRef.current)
  return true
}, [])

It's also important that the component unions the selected geometries (in case multiple features are selected), buffers the result depending on the spatial reference (geodesic, WGS84/Web Mercator, or planar), and adds the graphic to the layer. The buffer layer is then cleaned up automatically when you switch filter modes or reset the widget.

It's a bit of an ad hoc solution, but it works!

View solution in original post

4 Replies
JeffreyThompson2
MVP Frequent Contributor

Yes, you are correct. The Selected Features From A Datasource option in the Query Widget does not show a visual representation of its buffer. There is one with the Drawn Graphic option.

You may consider using Near Me instead. There is a lot of overlap between Near Me and Query and Near Me shows its buffer area.

GIS Developer
City of Arlington, Texas
Agrizz
by
Occasional Contributor

I submitted an idea for this last week!

Visible Buffer for Spatial Query Widget - Esri Community

JudithWammack
Frequent Contributor

I agree with @JeffreyThompson2 on this. Near me is what I use for my tax parcels for my end users.

ncramer11
Occasional Contributor

Update -- Solved using Developer Edition!

@JeffreyThompson2 you were right that the visual buffer was missing from the "Feature from Data Source" mode. With some help from Claude, I was able to modify the Query widget's source code to add the buffer graphic. I'll try to explain as best I can.

 

The widget has two separate geometry components in src/runtime/:

  • geometry-from-draw.tsx — already creates a buffer graphic on the map
  • geometry-from-ds.tsx — calculates the buffer for the query, but never visualizes it

geometry-from-ds.tsx needs the same buffer infrastructure as the draw component. The challenge is getting access to the map view. The draw component relies on spatialMapWidgetIds being configured, but using only the DS filter may never set that. The solution is MapViewManager, which tracks map views in the app without needing explicit widget configuration:

import { MapViewManager, type JimuMapView } from 'jimu-arcgis'

const ensureBufferLayer = React.useCallback(async (): Promise<boolean> => {
  if (bufferLayerRef.current) return true
  const mvManager = MapViewManager.getInstance()
  const ids = mvManager.getAllJimuMapViewIds()
  if (!ids?.length) return false
  const jimuMapView: JimuMapView = mvManager.getJimuMapViewById(ids[0])
  if (!jimuMapView?.view) return false
  jimuMapViewRef.current = jimuMapView
  const GraphicsLayer = await loadArcGISJSAPIModule('esri/layers/GraphicsLayer')
  bufferLayerRef.current = new GraphicsLayer()
  jimuMapView.view.map.add(bufferLayerRef.current)
  return true
}, [])

It's also important that the component unions the selected geometries (in case multiple features are selected), buffers the result depending on the spatial reference (geodesic, WGS84/Web Mercator, or planar), and adds the graphic to the layer. The buffer layer is then cleaned up automatically when you switch filter modes or reset the widget.

It's a bit of an ad hoc solution, but it works!