<?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 How to retrieve province, municipality, ward no and district? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537518#M50106</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following JavaScript code that I use to retrieve&amp;nbsp;province, municipality, ward no and district. Now I want to put inside its own variable, how can I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script&amp;gt;&lt;BR /&gt; var lon;&lt;BR /&gt; var lat;&lt;BR /&gt; var latlon;&lt;BR /&gt; var provinces;&lt;BR /&gt; var municipalities;&lt;BR /&gt; var districts;&lt;BR /&gt; var wards;&lt;BR /&gt; require([&lt;BR /&gt; "esri/Map",&lt;BR /&gt; "esri/views/MapView",&lt;BR /&gt; "esri/WebMap",&lt;BR /&gt; "esri/layers/FeatureLayer",&lt;BR /&gt; "esri/tasks/QueryTask",&lt;BR /&gt; "esri/tasks/support/Query",&lt;BR /&gt; "esri/config",&lt;BR /&gt; "esri/widgets/Sketch",&lt;BR /&gt; "esri/layers/GraphicsLayer"], &lt;BR /&gt; &lt;BR /&gt; function(Map, MapView, WebMap, FeatureLayer, QueryTask, Query,&lt;BR /&gt; esriConfig, Sketch, GraphicsLayer) {&lt;BR /&gt; esriConfig.portalUrl = "https://portal.environment.gov.za/portal";&lt;/P&gt;&lt;P&gt;const featureLayerUrl = 'https://portal.environment.gov.za/server/rest/services/Boundary/Wards/MapServer/0';&lt;BR /&gt; var webmap = new WebMap({&lt;BR /&gt; portalItem: {&lt;BR /&gt; id: "04582be14885483da48f29398960f653"&lt;BR /&gt; }&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; var graphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;var view = new MapView({&lt;BR /&gt; map: webmap,&lt;BR /&gt; container: "viewDiv",&lt;BR /&gt; popup: null&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; var featureLayer = new FeatureLayer({&lt;BR /&gt; url: featureLayerUrl&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;webmap.add(featureLayer);&lt;/P&gt;&lt;P&gt;webmap.layers.add(graphicsLayer);&lt;BR /&gt; &lt;BR /&gt; var sketch = new Sketch({&lt;BR /&gt; layer: graphicsLayer,&lt;BR /&gt; view: view, &lt;BR /&gt; creationMode: "update",&lt;BR /&gt; &lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; view.ui.add(sketch, {&lt;BR /&gt; position: "top-right"&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; sketch.on('create', function (event) {&lt;BR /&gt; // check if the create event's state has changed to complete indicating&lt;BR /&gt; // the graphic create operation is completed.&lt;BR /&gt; if (event.state === "complete") {&lt;/P&gt;&lt;P&gt;if (view.zoom &amp;gt;= 11) {&lt;BR /&gt; let gra = event.graphic.clone();&lt;BR /&gt; event.graphic.layer.removeAll();&lt;BR /&gt; gra.symbol.color = "red";&lt;BR /&gt; gra.layer.add(gra);&lt;BR /&gt; console.log(view.zoom);&lt;BR /&gt; console.log("X = ", gra.geometry.x);&lt;BR /&gt; console.log("Y = ", gra.geometry.y);&lt;BR /&gt; console.log("Lat = ", event.graphic.geometry.latitude);&lt;BR /&gt; console.log("Long = ", event.graphic.geometry.longitude);&lt;BR /&gt; lat = event.graphic.geometry.latitude;&lt;BR /&gt; lon = event.graphic.geometry.longitude;&lt;BR /&gt; zoomLevel = view.zoom;&lt;BR /&gt; for (var i = 0; i &amp;lt; gra.geometry.rings.length; i++){&lt;BR /&gt; for (var p = 0; p &amp;lt; gra.geometry.rings&lt;I&gt;.length; p++){&lt;BR /&gt; var LatLon = String(gra.geometry.rings&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;);&lt;BR /&gt; console.log(LatLon);&lt;BR /&gt; latlon = LatLon;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; debugger;&lt;BR /&gt; }&lt;BR /&gt; else{&lt;BR /&gt; alert("please zoom in");&lt;BR /&gt; event.graphic.layer.remove(event.graphic);&lt;BR /&gt; }&lt;BR /&gt; } &lt;BR /&gt; &lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; view.on('click', function(event){&lt;BR /&gt; var queryTask = new QueryTask({&lt;BR /&gt; url: featureLayerUrl&lt;BR /&gt; });&lt;BR /&gt; var query = new Query();&lt;BR /&gt; query.geometry = view.toMap(event);&lt;BR /&gt; query.distance = 0;&lt;BR /&gt; query.units = "meters";&lt;BR /&gt; query.spatialRelationship = "intersects";&lt;BR /&gt; query.returnGeometry = true;&lt;BR /&gt; query.outFields = [ "PROVINCE", "DCS12_NAME", "S12_NAME", "WARD_NO" ];&lt;/P&gt;&lt;P&gt;queryTask.execute(query).then(function(results){&lt;BR /&gt; console.log(results.features[0].attributes);&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; });&lt;BR /&gt; });&lt;BR /&gt; &amp;lt;/script&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 May 2020 11:44:28 GMT</pubDate>
    <dc:creator>SiyabongaKubeka</dc:creator>
    <dc:date>2020-05-19T11:44:28Z</dc:date>
    <item>
      <title>How to retrieve province, municipality, ward no and district?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537518#M50106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following JavaScript code that I use to retrieve&amp;nbsp;province, municipality, ward no and district. Now I want to put inside its own variable, how can I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script&amp;gt;&lt;BR /&gt; var lon;&lt;BR /&gt; var lat;&lt;BR /&gt; var latlon;&lt;BR /&gt; var provinces;&lt;BR /&gt; var municipalities;&lt;BR /&gt; var districts;&lt;BR /&gt; var wards;&lt;BR /&gt; require([&lt;BR /&gt; "esri/Map",&lt;BR /&gt; "esri/views/MapView",&lt;BR /&gt; "esri/WebMap",&lt;BR /&gt; "esri/layers/FeatureLayer",&lt;BR /&gt; "esri/tasks/QueryTask",&lt;BR /&gt; "esri/tasks/support/Query",&lt;BR /&gt; "esri/config",&lt;BR /&gt; "esri/widgets/Sketch",&lt;BR /&gt; "esri/layers/GraphicsLayer"], &lt;BR /&gt; &lt;BR /&gt; function(Map, MapView, WebMap, FeatureLayer, QueryTask, Query,&lt;BR /&gt; esriConfig, Sketch, GraphicsLayer) {&lt;BR /&gt; esriConfig.portalUrl = "https://portal.environment.gov.za/portal";&lt;/P&gt;&lt;P&gt;const featureLayerUrl = 'https://portal.environment.gov.za/server/rest/services/Boundary/Wards/MapServer/0';&lt;BR /&gt; var webmap = new WebMap({&lt;BR /&gt; portalItem: {&lt;BR /&gt; id: "04582be14885483da48f29398960f653"&lt;BR /&gt; }&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; var graphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;var view = new MapView({&lt;BR /&gt; map: webmap,&lt;BR /&gt; container: "viewDiv",&lt;BR /&gt; popup: null&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; var featureLayer = new FeatureLayer({&lt;BR /&gt; url: featureLayerUrl&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;webmap.add(featureLayer);&lt;/P&gt;&lt;P&gt;webmap.layers.add(graphicsLayer);&lt;BR /&gt; &lt;BR /&gt; var sketch = new Sketch({&lt;BR /&gt; layer: graphicsLayer,&lt;BR /&gt; view: view, &lt;BR /&gt; creationMode: "update",&lt;BR /&gt; &lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; view.ui.add(sketch, {&lt;BR /&gt; position: "top-right"&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; sketch.on('create', function (event) {&lt;BR /&gt; // check if the create event's state has changed to complete indicating&lt;BR /&gt; // the graphic create operation is completed.&lt;BR /&gt; if (event.state === "complete") {&lt;/P&gt;&lt;P&gt;if (view.zoom &amp;gt;= 11) {&lt;BR /&gt; let gra = event.graphic.clone();&lt;BR /&gt; event.graphic.layer.removeAll();&lt;BR /&gt; gra.symbol.color = "red";&lt;BR /&gt; gra.layer.add(gra);&lt;BR /&gt; console.log(view.zoom);&lt;BR /&gt; console.log("X = ", gra.geometry.x);&lt;BR /&gt; console.log("Y = ", gra.geometry.y);&lt;BR /&gt; console.log("Lat = ", event.graphic.geometry.latitude);&lt;BR /&gt; console.log("Long = ", event.graphic.geometry.longitude);&lt;BR /&gt; lat = event.graphic.geometry.latitude;&lt;BR /&gt; lon = event.graphic.geometry.longitude;&lt;BR /&gt; zoomLevel = view.zoom;&lt;BR /&gt; for (var i = 0; i &amp;lt; gra.geometry.rings.length; i++){&lt;BR /&gt; for (var p = 0; p &amp;lt; gra.geometry.rings&lt;I&gt;.length; p++){&lt;BR /&gt; var LatLon = String(gra.geometry.rings&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;);&lt;BR /&gt; console.log(LatLon);&lt;BR /&gt; latlon = LatLon;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; debugger;&lt;BR /&gt; }&lt;BR /&gt; else{&lt;BR /&gt; alert("please zoom in");&lt;BR /&gt; event.graphic.layer.remove(event.graphic);&lt;BR /&gt; }&lt;BR /&gt; } &lt;BR /&gt; &lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; view.on('click', function(event){&lt;BR /&gt; var queryTask = new QueryTask({&lt;BR /&gt; url: featureLayerUrl&lt;BR /&gt; });&lt;BR /&gt; var query = new Query();&lt;BR /&gt; query.geometry = view.toMap(event);&lt;BR /&gt; query.distance = 0;&lt;BR /&gt; query.units = "meters";&lt;BR /&gt; query.spatialRelationship = "intersects";&lt;BR /&gt; query.returnGeometry = true;&lt;BR /&gt; query.outFields = [ "PROVINCE", "DCS12_NAME", "S12_NAME", "WARD_NO" ];&lt;/P&gt;&lt;P&gt;queryTask.execute(query).then(function(results){&lt;BR /&gt; console.log(results.features[0].attributes);&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; });&lt;BR /&gt; });&lt;BR /&gt; &amp;lt;/script&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2020 11:44:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537518#M50106</guid>
      <dc:creator>SiyabongaKubeka</dc:creator>
      <dc:date>2020-05-19T11:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve province, municipality, ward no and district?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537519#M50107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are almost there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;queryTask&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;execute&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;then&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;results&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; feat &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; results&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  provinces &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feat&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attributes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;PROVINCE&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  wards &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feat&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attributes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;WARD_NO&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  districts &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feat&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attributes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DCS12_NAME&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  municipalities &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feat&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attributes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;S12_NAME
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537519#M50107</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T23:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve province, municipality, ward no and district?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537520#M50108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2020 07:42:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-retrieve-province-municipality-ward-no-and/m-p/537520#M50108</guid>
      <dc:creator>SiyabongaKubeka</dc:creator>
      <dc:date>2020-05-20T07:42:22Z</dc:date>
    </item>
  </channel>
</rss>

