<?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: Styling sketchViewModel in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1068879#M73517</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/493343"&gt;@JGraca&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;If you want the polygon fill to be transparent then you need to set the fill style and if want the outline to be dashed then you have to set the outline style.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  polygonSymbol: {
    type: "simple-fill",
    color: [0, 0, 0, 0.2],
    style: "none",
    outline: {
      style: "dash",
      color: [255, 255, 255],
      width: 2
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Jun 2021 13:55:13 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2021-06-16T13:55:13Z</dc:date>
    <item>
      <title>Styling sketchViewModel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1068857#M73516</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;API Version 4.18&lt;/P&gt;&lt;P&gt;My current situation for this code is no matter what i do following the documentation, the inside of my area polygon is always blue and i need it to be transparent. Also, the polygon needs to be dashed and the code builds full lines. Basically, the whole style does not change no matter what i write.&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const sketchViewModel = new SketchViewModel({
  view: mapView,
  layer: layers.search,
  updateOnGraphicClick: true,
  defaultUpdateOptions: {
    enableRotation: false,
    toggleToolOnClick: false
  },
  polygonSymbol: {
    type: "simple-fill",
    color: [0, 0, 0, 0.2],
    outline: {
      color: [255, 255, 255],
      width: 2
    }
  }
})​&lt;/LI-CODE&gt;&lt;P&gt;What i get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JGraca_0-1623848907438.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16090i067C67B96295B997/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JGraca_0-1623848907438.png" alt="JGraca_0-1623848907438.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JGraca_1-1623848953489.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16091i52A1521C72CC7E45/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JGraca_1-1623848953489.png" alt="JGraca_1-1623848953489.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 13:10:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1068857#M73516</guid>
      <dc:creator>JGraca</dc:creator>
      <dc:date>2021-06-16T13:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Styling sketchViewModel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1068879#M73517</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/493343"&gt;@JGraca&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;If you want the polygon fill to be transparent then you need to set the fill style and if want the outline to be dashed then you have to set the outline style.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  polygonSymbol: {
    type: "simple-fill",
    color: [0, 0, 0, 0.2],
    style: "none",
    outline: {
      style: "dash",
      color: [255, 255, 255],
      width: 2
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 13:55:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1068879#M73517</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-06-16T13:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Styling sketchViewModel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1069600#M73529</link>
      <description>&lt;P&gt;Hi, thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1104"&gt;@RobertScheitlin__GISP&lt;/a&gt;&amp;nbsp;for the reply.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have done what you suggested and it worked, but i would like to change the following:&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;- Remove the orange lines from the border;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;- Change the boxes border colors to grey (the ones you draw on);&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;- Allow the polygon to be always resized;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JGraca_0-1623965689006.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16240i0296D57E29F35295/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JGraca_0-1623965689006.png" alt="JGraca_0-1623965689006.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On a different project, the background and the border still is with the blue colors.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JGraca_1-1623965726743.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16241iC52EFCF7D6127EE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JGraca_1-1623965726743.png" alt="JGraca_1-1623965726743.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On &lt;A href="https://codepen.io/jgodinho/pen/xxqgdyj?editors=1000" target="_self"&gt;codepen&lt;/A&gt;&amp;nbsp;it worked&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 21:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1069600#M73529</guid>
      <dc:creator>JGraca</dc:creator>
      <dc:date>2021-06-17T21:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Styling sketchViewModel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1069829#M73538</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/493343"&gt;@JGraca&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Here is your codepen code updated for that:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;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;style&amp;gt;
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  &amp;lt;/style&amp;gt;

  &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.18/esri/themes/light/main.css" /&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.18/"&amp;gt;&amp;lt;/script&amp;gt;

  &amp;lt;script&amp;gt;
    require(["esri/views/MapView",
      "esri/WebMap",
      "esri/Graphic",
      "esri/layers/GraphicsLayer",
      "esri/widgets/Sketch/SketchViewModel",
      "esri/geometry/Polygon",
      "esri/geometry/SpatialReference",
      "esri/geometry/support/webMercatorUtils"
    ], function (MapView, WebMap, Graphic, GraphicsLayer, SketchViewModel, Polygon, SpatialReference, webMercatorUtils) {

      let sketchViewModel;


      var graphicsLayer = new GraphicsLayer();
      var webmap = new WebMap({
        basemap: 'satellite',
        layers: [graphicsLayer]
      });

      var view = new MapView({
        map: webmap,
        container: "viewDiv",
        center: [-9.40019762581224, 39.33930907833357],
        zoom: 6
      });

      setUpGraphicClickHandler();

      addGraphics();

      sketchViewModel = new SketchViewModel({
        view: view,
        layer: graphicsLayer,
        updateOnGraphicClick: true,
        defaultUpdateOptions: {
          enableRotation: false,
          toggleToolOnClick: false
        },
        polygonSymbol: {
          type: "simple-fill",
          color: [0, 0, 0, 0.2],
          style: "none",
          outline: {
            style: "dash",
            color: [168,168,168,1],
            width: 2
          }
        }
      });

      sketchViewModel.on(["update", "undo", "redo"], onGraphicUpdate);

      function onGraphicUpdate(event) {
        const graphic = event.graphics[0];

        if (
          event.toolEventInfo &amp;amp;&amp;amp;
          (event.toolEventInfo.type === "move-stop" ||
            event.toolEventInfo.type === "reshape-stop")
        ) {
          sketchViewModel.complete();
        } else if (event.state === "cancel" || event.state === "complete") {
          sketchViewModel.update([graphic], {
            tool: "rectangle"
          });
          
          const coordinate = webMercatorUtils.webMercatorToGeographic({graphic})
        }
        sketchViewModel._internalGraphicsLayer.graphics.map(function(gra){
          if(gra.geometry.type === 'polygon'){
            gra.symbol.outline.color = [0,0,0,0];
          }
          if(gra.geometry.type === 'point'){
            gra.symbol.outline.color = [168,168,168,1];
          }
        });
      }

      function setUpGraphicClickHandler() {
        view.on("click", function (event) {
          if (sketchViewModel.state === "active") {
            return;
          }
          
          view.hitTest(event).then(function (response) {
            var results = response.results;
            
            results.forEach(function (result) {
              if (
                result.graphic.layer === sketchViewModel.layer &amp;amp;&amp;amp;
                result.graphic.attributes &amp;amp;&amp;amp;
                result.graphic.attributes.newDevelopment
              ) {
                sketchViewModel.update([result.graphic], {
                  tool: "rectangle"
                });
              }
            });
          });
        });
      }

      function addGraphics() {
        const newDevelopmentGraphic = new Graphic({
          geometry: webMercatorUtils.geographicToWebMercator(
            new Polygon({
              rings: [
                [-13.43218004768601, 43.353861447707416],
                [-13.43218004768601, 36.364593011258414],
                [2.497995733559755, 36.364593011258414],
                [2.497995733559755, 43.353861447707416],
                [-13.43218004768601, 43.353861447707416]
              ],
              spatialReference: new SpatialReference({
                wkid: 3857
              })
            })
          ),
          symbol: {
            type: "simple-fill",
            color: [0, 0, 0, 0.2],
            style: "none",
            outline: {
              style: "dash",
              color: [168,168,168,1],
              width: 2
            }
          },
          attributes: {
            newDevelopment: "search area"
          }
        });
        
        graphicsLayer.add(newDevelopmentGraphic);
        setTimeout(function(){
          sketchViewModel.update([newDevelopmentGraphic],{
            tool: "transform",
            toggleToolOnClick: false
          });
        }, 500);
      }
    });
  &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>Fri, 18 Jun 2021 14:51:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/styling-sketchviewmodel/m-p/1069829#M73538</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-06-18T14:51:57Z</dc:date>
    </item>
  </channel>
</rss>

