<?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 Re: PointDrawAction Event Listener Working example? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1119597#M75379</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/328316"&gt;@DaleBecker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample for that:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;Draw point | Sample | ArcGIS API for JavaScript 4.21&amp;lt;/title&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.21/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.21/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    &amp;lt;/style&amp;gt;
    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/views/draw/Draw",
        "esri/Graphic",
        "esri/layers/GraphicsLayer"
      ], (Map, MapView, Draw, Graphic, GraphicsLayer) =&amp;gt; {
        const drawGL = new GraphicsLayer({
          id: "draw Graphics Layer"
        });
        
        const map = new Map({
          basemap: "gray-vector",
          layers:[drawGL]
        });
        
        const view = new MapView({
          container: "viewDiv",
          map: map,
          zoom: 15,
          center: [18.06, 59.34]
        });
        //map.addLayer(drawGL)

        const draw = new Draw({
          view: view
        });
        
        view.when(()=&amp;gt;{
          setDrawAction();
        });
        
        function setDrawAction() {
          let action = draw.create("point");

          // PointDrawAction.cursor-update
          // Give a visual feedback to users as they move the pointer over the view
          action.on("cursor-update", function (evt) {
            createPointGraphic(evt.coordinates);
          });
        
          // PointDrawAction.draw-complete
          // Create a point when user clicks on the view or presses "C" key.
          action.on("draw-complete", function (evt) {
            createPointGraphic(evt.coordinates, true);
            setDrawAction();
          });
        }
        
        function createPointGraphic(coordinates, addToGL){
          view.graphics.removeAll();
          let point = {
            type: "point", // autocasts as /Point
            x: coordinates[0],
            y: coordinates[1],
            spatialReference: view.spatialReference
          };
        
          let graphic = new Graphic({
            geometry: point,
            symbol: {
              type: "simple-marker", // autocasts as SimpleMarkerSymbol
              style: "square",
              color: "red",
              size: "16px",
              outline: { // autocasts as SimpleLineSymbol
                color: [255, 255, 0],
                width: 3
              }
            }
          });
          if(addToGL){
            drawGL.removeAll();
            drawGL.add(graphic);
          }else{
            view.graphics.add(graphic);
          }
        }
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 23 Nov 2021 17:10:04 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2021-11-23T17:10:04Z</dc:date>
    <item>
      <title>PointDrawAction Event Listener Working example?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1119582#M75378</link>
      <description>&lt;P&gt;I am trying to implement PointDrawAction by adding to the code example at:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-PointDrawAction.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-PointDrawAction.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;My goal is to have the draw tool enabled on map load so that a user does not need to click on a widget button but just clicks on the map to select a point and a graphic marker will be added. When they click on a different point the 1st graphic should be removed and a new graphic created.&lt;/P&gt;&lt;P&gt;I tried simple adding a minimal event listener to the example code in the docs but it did not work:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;on&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Click"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;enableCreatePoint&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any advice or examples you can point me to would be very helpful.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Nov 2021 16:45:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1119582#M75378</guid>
      <dc:creator>DaleBecker</dc:creator>
      <dc:date>2021-11-23T16:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: PointDrawAction Event Listener Working example?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1119597#M75379</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/328316"&gt;@DaleBecker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample for that:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;Draw point | Sample | ArcGIS API for JavaScript 4.21&amp;lt;/title&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.21/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.21/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    &amp;lt;/style&amp;gt;
    &amp;lt;script&amp;gt;
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/views/draw/Draw",
        "esri/Graphic",
        "esri/layers/GraphicsLayer"
      ], (Map, MapView, Draw, Graphic, GraphicsLayer) =&amp;gt; {
        const drawGL = new GraphicsLayer({
          id: "draw Graphics Layer"
        });
        
        const map = new Map({
          basemap: "gray-vector",
          layers:[drawGL]
        });
        
        const view = new MapView({
          container: "viewDiv",
          map: map,
          zoom: 15,
          center: [18.06, 59.34]
        });
        //map.addLayer(drawGL)

        const draw = new Draw({
          view: view
        });
        
        view.when(()=&amp;gt;{
          setDrawAction();
        });
        
        function setDrawAction() {
          let action = draw.create("point");

          // PointDrawAction.cursor-update
          // Give a visual feedback to users as they move the pointer over the view
          action.on("cursor-update", function (evt) {
            createPointGraphic(evt.coordinates);
          });
        
          // PointDrawAction.draw-complete
          // Create a point when user clicks on the view or presses "C" key.
          action.on("draw-complete", function (evt) {
            createPointGraphic(evt.coordinates, true);
            setDrawAction();
          });
        }
        
        function createPointGraphic(coordinates, addToGL){
          view.graphics.removeAll();
          let point = {
            type: "point", // autocasts as /Point
            x: coordinates[0],
            y: coordinates[1],
            spatialReference: view.spatialReference
          };
        
          let graphic = new Graphic({
            geometry: point,
            symbol: {
              type: "simple-marker", // autocasts as SimpleMarkerSymbol
              style: "square",
              color: "red",
              size: "16px",
              outline: { // autocasts as SimpleLineSymbol
                color: [255, 255, 0],
                width: 3
              }
            }
          });
          if(addToGL){
            drawGL.removeAll();
            drawGL.add(graphic);
          }else{
            view.graphics.add(graphic);
          }
        }
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 23 Nov 2021 17:10:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1119597#M75379</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-11-23T17:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: PointDrawAction Event Listener Working example?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1192576#M77937</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;Thank you so much for the sample you provided, it helped me a ton ! It's exactly what I'm trying to do, except that contrary to what Dale was looking for, I would like to be able to insert this code in a widget (web Appbuilder) : the user would click on a widget button which would enable the creation of a point, which in turn would open a specific url in a new tab or window upon the click on the map.&lt;/P&gt;&lt;P&gt;I've been trying to simplify the Draw widget (&lt;A href="https://developers.arcgis.com/web-appbuilder/api-reference/draw.htm)" target="_blank"&gt;https://developers.arcgis.com/web-appbuilder/api-reference/draw.htm)&lt;/A&gt; but I'm not getting anywhere. Sorry if this is too easy or has been resolved before, I am new to this.&lt;/P&gt;&lt;P&gt;Thanks in advance !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 19:25:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pointdrawaction-event-listener-working-example/m-p/1192576#M77937</guid>
      <dc:creator>MarcBazin</dc:creator>
      <dc:date>2022-07-15T19:25:50Z</dc:date>
    </item>
  </channel>
</rss>

