<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Draw buffer around points in a feature layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173457#M77287</link>
    <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;I'm a very much new to JS and so am simply copying and pasting code from &lt;A href="https://developers.arcgis.com/javascript/latest/calculate-geometries/#create-a-buffer" target="_self"&gt;samples&lt;/A&gt;&amp;nbsp;to make this custom widget.&lt;/P&gt;&lt;P&gt;This is simply a hardcoded widget that when enabled will create buffers around a points hosted feature layer in AGOL (my own content).&amp;nbsp; My end goal is to use a field with distance values for the buffer sizes, but for now I just want them to draw a uniform buffer.&lt;/P&gt;&lt;P&gt;When I click on Enable Buffer, I don't see anything, but I'm not getting any error messages.&amp;nbsp; I'm using this in CodePen.&lt;/P&gt;&lt;P&gt;This is the code I'm using. The bold parts are where I think there could be an issue.&amp;nbsp; (I removed the style and html portion).&lt;/P&gt;&lt;P&gt;Much appreciate any feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JS :&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;"esri/config",&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/renderers/SimpleRenderer",&lt;BR /&gt;"esri/Graphic",&lt;BR /&gt;"esri/layers/GraphicsLayer",&lt;BR /&gt;"esri/geometry/geometryEngine"&lt;/P&gt;&lt;P&gt;], function(esriConfig, Map, MapView, FeatureLayer, SimpleRenderer, Graphic, GraphicsLayer, geometryEngine) {&lt;/P&gt;&lt;P&gt;esriConfig.apiKey = "deleted";&lt;BR /&gt;&lt;BR /&gt;//add basemap&lt;BR /&gt;const map = new Map({&lt;BR /&gt;basemap: "arcgis-imagery" //Basemap layer service&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;//add map view&lt;BR /&gt;const view = new MapView({&lt;BR /&gt;map: map,&lt;BR /&gt;center: [31.205, 49.627], //Longitude, latitude&lt;BR /&gt;zoom: 8,&lt;BR /&gt;container: "viewDiv"&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;//add new graphics layers for buffers&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;const graphicsLayer = new GraphicsLayer();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;const resultsLayer = new GraphicsLayer();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;map.addMany([graphicsLayer, resultsLayer]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// define style for GPS points layer&lt;BR /&gt;let GPS_Renderer = {&lt;BR /&gt;type: "simple", // autocasts as new SimpleRenderer()&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-marker", // autocasts as new SimpleMarkerSymbol()&lt;BR /&gt;size: 6,&lt;BR /&gt;color: "orange",&lt;BR /&gt;outline: { // autocasts as new SimpleLineSymbol()&lt;BR /&gt;width: 0.5,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;// add feature layer from URL --&lt;BR /&gt;const hitsGPS = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services8.arcgis.com/39j38RHYsO16guxW/arcgis/rest/services/GPS_Hits/FeatureServer" target="_blank" rel="noopener"&gt;https://services8.arcgis.com/39j38RHYsO16guxW/arcgis/rest/services/GPS_Hits/FeatureServer&lt;/A&gt;",&lt;BR /&gt;renderer: GPS_Renderer&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;// add GPS layer to the map&lt;BR /&gt;map.add(hitsGPS);&lt;BR /&gt;&lt;BR /&gt;// add controls to the top of the screen&lt;BR /&gt;view.ui.add(document.getElementById("controls"), "top-right");&lt;BR /&gt;&lt;STRONG&gt;document.getElementById("buffer").addEventListener("click", createBuffer);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;document.getElementById("reset").addEventListener("click", resetGraphics);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// create buffer function&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;let bufferGraphic;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;function createBuffer() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (bufferGraphic) {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// execute buffer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const buffer = geometryEngine.geodesicBuffer(&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;hitsGPS.geometry,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;100,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"kilometers"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// save resulting buffer as graphic&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;bufferGraphic = new Graphic({&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;geometry: buffer,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;symbol: {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;type: "simple-fill",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;color: [227, 139, 79, 0.25],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;outline: {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;color: [255, 255, 255, 255],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;},&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;},&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;});&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// add graphic to map&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;graphicsLayer.add(bufferGraphic);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// reset function&lt;/P&gt;&lt;P&gt;function resetGraphics() {&lt;BR /&gt;graphicsLayer.remove(bufferGraphic);&lt;BR /&gt;resultsLayer.removeAll();&lt;BR /&gt;bufferGraphic = null;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;div id="controls" class="esri-widget"&amp;gt;&lt;BR /&gt;&amp;lt;button id="buffer" class="esri-button"&amp;gt;Enable Buffer&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;lt;button id="reset" class="esri-button esri-button--secondary"&amp;gt;Disable Buffer&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2022 17:41:32 GMT</pubDate>
    <dc:creator>cptstubing16</dc:creator>
    <dc:date>2022-05-12T17:41:32Z</dc:date>
    <item>
      <title>Draw buffer around points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173457#M77287</link>
      <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;I'm a very much new to JS and so am simply copying and pasting code from &lt;A href="https://developers.arcgis.com/javascript/latest/calculate-geometries/#create-a-buffer" target="_self"&gt;samples&lt;/A&gt;&amp;nbsp;to make this custom widget.&lt;/P&gt;&lt;P&gt;This is simply a hardcoded widget that when enabled will create buffers around a points hosted feature layer in AGOL (my own content).&amp;nbsp; My end goal is to use a field with distance values for the buffer sizes, but for now I just want them to draw a uniform buffer.&lt;/P&gt;&lt;P&gt;When I click on Enable Buffer, I don't see anything, but I'm not getting any error messages.&amp;nbsp; I'm using this in CodePen.&lt;/P&gt;&lt;P&gt;This is the code I'm using. The bold parts are where I think there could be an issue.&amp;nbsp; (I removed the style and html portion).&lt;/P&gt;&lt;P&gt;Much appreciate any feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JS :&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;"esri/config",&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/renderers/SimpleRenderer",&lt;BR /&gt;"esri/Graphic",&lt;BR /&gt;"esri/layers/GraphicsLayer",&lt;BR /&gt;"esri/geometry/geometryEngine"&lt;/P&gt;&lt;P&gt;], function(esriConfig, Map, MapView, FeatureLayer, SimpleRenderer, Graphic, GraphicsLayer, geometryEngine) {&lt;/P&gt;&lt;P&gt;esriConfig.apiKey = "deleted";&lt;BR /&gt;&lt;BR /&gt;//add basemap&lt;BR /&gt;const map = new Map({&lt;BR /&gt;basemap: "arcgis-imagery" //Basemap layer service&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;//add map view&lt;BR /&gt;const view = new MapView({&lt;BR /&gt;map: map,&lt;BR /&gt;center: [31.205, 49.627], //Longitude, latitude&lt;BR /&gt;zoom: 8,&lt;BR /&gt;container: "viewDiv"&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;//add new graphics layers for buffers&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;const graphicsLayer = new GraphicsLayer();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;const resultsLayer = new GraphicsLayer();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;map.addMany([graphicsLayer, resultsLayer]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// define style for GPS points layer&lt;BR /&gt;let GPS_Renderer = {&lt;BR /&gt;type: "simple", // autocasts as new SimpleRenderer()&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-marker", // autocasts as new SimpleMarkerSymbol()&lt;BR /&gt;size: 6,&lt;BR /&gt;color: "orange",&lt;BR /&gt;outline: { // autocasts as new SimpleLineSymbol()&lt;BR /&gt;width: 0.5,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;// add feature layer from URL --&lt;BR /&gt;const hitsGPS = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services8.arcgis.com/39j38RHYsO16guxW/arcgis/rest/services/GPS_Hits/FeatureServer" target="_blank" rel="noopener"&gt;https://services8.arcgis.com/39j38RHYsO16guxW/arcgis/rest/services/GPS_Hits/FeatureServer&lt;/A&gt;",&lt;BR /&gt;renderer: GPS_Renderer&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;// add GPS layer to the map&lt;BR /&gt;map.add(hitsGPS);&lt;BR /&gt;&lt;BR /&gt;// add controls to the top of the screen&lt;BR /&gt;view.ui.add(document.getElementById("controls"), "top-right");&lt;BR /&gt;&lt;STRONG&gt;document.getElementById("buffer").addEventListener("click", createBuffer);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;document.getElementById("reset").addEventListener("click", resetGraphics);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// create buffer function&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;let bufferGraphic;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;function createBuffer() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (bufferGraphic) {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// execute buffer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const buffer = geometryEngine.geodesicBuffer(&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;hitsGPS.geometry,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;100,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"kilometers"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// save resulting buffer as graphic&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;bufferGraphic = new Graphic({&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;geometry: buffer,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;symbol: {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;type: "simple-fill",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;color: [227, 139, 79, 0.25],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;outline: {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;color: [255, 255, 255, 255],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;},&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;},&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;});&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// add graphic to map&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;graphicsLayer.add(bufferGraphic);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// reset function&lt;/P&gt;&lt;P&gt;function resetGraphics() {&lt;BR /&gt;graphicsLayer.remove(bufferGraphic);&lt;BR /&gt;resultsLayer.removeAll();&lt;BR /&gt;bufferGraphic = null;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;div id="controls" class="esri-widget"&amp;gt;&lt;BR /&gt;&amp;lt;button id="buffer" class="esri-button"&amp;gt;Enable Buffer&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;lt;button id="reset" class="esri-button esri-button--secondary"&amp;gt;Disable Buffer&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 17:41:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173457#M77287</guid>
      <dc:creator>cptstubing16</dc:creator>
      <dc:date>2022-05-12T17:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Draw buffer around points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173462#M77288</link>
      <description>&lt;P&gt;You can not call hitsGPS.geometry. HitsGPS is a featurelayer and does not have a geometry property you have to iterate over the results of a query on the featurelayer.&amp;nbsp;&amp;nbsp;Something like this (untested code)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const sym = {
  type: "simple-fill",
  color: [227, 139, 79, 0.25],
  style: "solid",
  outline: {
    color: [255, 255, 255, 255],
    width: 1
  }
};
hitsGPS.queryFeatures().then(results){
  results.features.map(feat =&amp;gt; {
    const buffer = geometryEngine.geodesicBuffer(feat.geometry, 100, "kilometers");
    bufferGraphic = new Graphic({geometry: buffer, symbol: sym});
    // add graphic to map
    graphicsLayer.add(bufferGraphic);
  });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 18:06:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173462#M77288</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2022-05-12T18:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Draw buffer around points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173863#M77301</link>
      <description>&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;Thanks for this answer.&amp;nbsp; I added the code and it works but the range ring doesn't appear but that's an Uncaught TypeError I will figure out.&amp;nbsp; But this looks promising.&lt;/P&gt;&lt;P&gt;If I wanted to use a field value for the distance instead of a hardcoded distance, is it possible to use a variable in place of the '100'?&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 18:43:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173863#M77301</guid>
      <dc:creator>cptstubing16</dc:creator>
      <dc:date>2022-05-13T18:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Draw buffer around points in a feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173889#M77302</link>
      <description>&lt;P&gt;Sure you can easily do that inside the feature loop.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;hitsGPS.queryFeatures().then(results){
  results.features.map(feat =&amp;gt; {
    const buffer = geometryEngine.geodesicBuffer(feat.geometry, parseInt(feat.attributes['someFieldName']), "kilometers");
    bufferGraphic = new Graphic({geometry: buffer, symbol: sym});
    // add graphic to map
    graphicsLayer.add(bufferGraphic);
  });
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 13 May 2022 19:11:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-buffer-around-points-in-a-feature-layer/m-p/1173889#M77302</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2022-05-13T19:11:17Z</dc:date>
    </item>
  </channel>
</rss>

