<?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: dojo.connect(this.editToolbar,'onGraphicClick'...) How to add graphic on the map in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221480#M78997</link>
    <description>&lt;P&gt;Thanks very much &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp; ! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Indeed It's seems OK like this :&lt;/P&gt;&lt;P&gt;&lt;EM&gt;dojo.connect(this.editToolbar,'onGraphicClick',&lt;STRONG&gt; lang.hitch(&lt;/STRONG&gt;this,function(feature,info){&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;this.dimensionGraphicsLayer.clear();&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 12:44:42 GMT</pubDate>
    <dc:creator>ChristopheDALICHAMPT</dc:creator>
    <dc:date>2022-10-13T12:44:42Z</dc:date>
    <item>
      <title>dojo.connect(this.editToolbar,'onGraphicClick'...) How to add graphic on the map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221245#M78986</link>
      <description>&lt;P&gt;Hi. I would like to add text graphic on the map to add informations about the dimensions of the polygon which is selected when the EditToolBar is selected.&lt;/P&gt;&lt;P&gt;To do that I use dojo.connect(this.editToolbar,'onGraphicClick',function(feature,info)&lt;/P&gt;&lt;P&gt;How, inside this function can I write graphics in a GraphicLayer ? Indeed It seems that I cannot "reach" the variable of the graphicLayer I created on widget startup (undefined dimensionGraphicLayer) ?&lt;/P&gt;&lt;P&gt;_activateEditToolbar: function (feature) {&lt;BR /&gt;var layer = feature.getLayer();&lt;BR /&gt;&lt;BR /&gt;if (this.editToolbar.getCurrentState().tool !== 0) {&lt;BR /&gt;this.editToolbar.deactivate();&lt;BR /&gt;}&lt;BR /&gt;switch (layer.geometryType) {&lt;BR /&gt;case "esriGeometryPoint":&lt;BR /&gt;this.editToolbar.activate(Edit.MOVE, feature);&lt;BR /&gt;break;&lt;BR /&gt;case "esriGeometryPolyline":&lt;BR /&gt;case "esriGeometryPolygon":&lt;BR /&gt;/*jslint bitwise: true*/&lt;BR /&gt;this.editToolbar.activate(Edit.EDIT_VERTICES |&lt;BR /&gt;Edit.MOVE |&lt;BR /&gt;Edit.ROTATE |&lt;BR /&gt;Edit.SCALE, feature);&lt;BR /&gt;/*jslint bitwise: false*/&lt;BR /&gt;&lt;BR /&gt;/*draw text graphics on the polygon */&lt;BR /&gt;dojo.connect(this.editToolbar,'onGraphicClick',function(feature,info){&lt;BR /&gt;&lt;BR /&gt;var distanceUnits = "meters";&lt;BR /&gt;var pgeometry = feature.geometry;&lt;BR /&gt;var pspatialReference = pgeometry.spatialReference&lt;BR /&gt;var prings = pgeometry.rings;&lt;/P&gt;&lt;P&gt;/*list that stores the point to place the graphics*/&lt;BR /&gt;var listePointMedian = [];&lt;/P&gt;&lt;P&gt;/*list that stores the distance to display*/&lt;BR /&gt;var listeDistance = [];&lt;BR /&gt;&lt;BR /&gt;prings.forEach(function(pring,index){&lt;BR /&gt;&lt;BR /&gt;var indexvertice = 0;&lt;BR /&gt;&lt;BR /&gt;while (indexvertice &amp;lt; pring.length - 1) {&lt;BR /&gt;&lt;BR /&gt;var pdepart = pring[indexvertice];&lt;BR /&gt;var xDepart = pdepart[0];&lt;BR /&gt;var yDepart = pdepart[1];&lt;BR /&gt;var pointDepart = new Point(xDepart,yDepart,pspatialReference);&lt;BR /&gt;&lt;BR /&gt;indexSuivant = indexvertice+1;&lt;BR /&gt;var parrivee = pring[indexSuivant];&lt;BR /&gt;var xArrivee = parrivee[0];&lt;BR /&gt;var yArrivee = parrivee[1];&lt;BR /&gt;var pointArrivee = new Point(xArrivee,yArrivee,pspatialReference);&lt;BR /&gt;&lt;BR /&gt;var xMedian = (xDepart + xArrivee)/2;&lt;BR /&gt;var yMedian = (yDepart + yArrivee)/2;&lt;BR /&gt;var pointMedian = new Point(xMedian,yMedian,pspatialReference);&lt;BR /&gt;&lt;BR /&gt;listePointMedian.push(pointMedian);&lt;BR /&gt;&lt;BR /&gt;var geometryService = new GeometryService("https://....../arcgis/rest/services/Utilities/Geometry/GeometryServer");&lt;BR /&gt;var distParams = new DistanceParameters();&lt;BR /&gt;distParams.distanceUnit = esri.tasks.GeometryService.UNIT_KILOMETER;&lt;BR /&gt;distParams.geometry1 = pointDepart;&lt;BR /&gt;distParams.geometry2 = pointArrivee;&lt;BR /&gt;distParams.geodesic = true;&lt;BR /&gt;&lt;BR /&gt;geometryService.distance(distParams, function(distance) {&lt;BR /&gt;&lt;BR /&gt;result = distance;&lt;BR /&gt;listeDistance.push(result);&lt;BR /&gt;&lt;BR /&gt;});&lt;BR /&gt;indexvertice++;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;},&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 19:10:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221245#M78986</guid>
      <dc:creator>ChristopheDALICHAMPT</dc:creator>
      <dc:date>2022-10-12T19:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: dojo.connect(this.editToolbar,'onGraphicClick'...) How to add graphic on the map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221258#M78988</link>
      <description>&lt;P&gt;You have to use &lt;A href="https://dojotoolkit.org/reference-guide/1.10/dojo/_base/lang.html#hitch" target="_self"&gt;lang.hitch&lt;/A&gt; to make sure you're getting the correct context of "this" in your function.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 19:59:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221258#M78988</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-10-12T19:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: dojo.connect(this.editToolbar,'onGraphicClick'...) How to add graphic on the map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221480#M78997</link>
      <description>&lt;P&gt;Thanks very much &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp; ! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Indeed It's seems OK like this :&lt;/P&gt;&lt;P&gt;&lt;EM&gt;dojo.connect(this.editToolbar,'onGraphicClick',&lt;STRONG&gt; lang.hitch(&lt;/STRONG&gt;this,function(feature,info){&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;this.dimensionGraphicsLayer.clear();&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 12:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dojo-connect-this-edittoolbar-ongraphicclick-how/m-p/1221480#M78997</guid>
      <dc:creator>ChristopheDALICHAMPT</dc:creator>
      <dc:date>2022-10-13T12:44:42Z</dc:date>
    </item>
  </channel>
</rss>

