Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
<head>
<meta charset="utf-8" />
  <meta
  name="viewport"
    content="initial-scale=1,maximum-scale=1,user-scalable=no"
      />
      <!--
      ArcGIS API for JavaScript, https://js.arcgis.com
        For more information about the layers-geojson sample, read the original sample description at developers.arcgis.com.
        https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson/index.html
          -->
<title>GeoJSONLayer | Sample | ArcGIS API for JavaScript 4.16</title>

<style>
html,
body,
#viewDiv {
  padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>

<link
rel="stylesheet"
href="https://js.arcgis.com/4.16/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.16/"></script>

<script>
require([
  "esri/Map",
  "esri/layers/CSVLayer",
  "esri/layers/FeatureLayer",
  "esri/widgets/Legend",
  "esri/views/MapView",
  "esri/widgets/Print","esri/geometry/Point",
  "dojo/_base/array",
  "esri/tasks/QueryTask",
  "esri/tasks/support/Query",
  "esri/widgets/Expand", 
  "esri/core/watchUtils",
  "dojo/query",
  "dojo/aspect",
  "esri/renderers/ClassBreaksRenderer",
  "esri/renderers/smartMapping/creators/size", 
  "dojo/dom", "dojo/domReady!"
  ], function (Map, CSVLayer,FeatureLayer, Legend, MapView, Print,Point,
    arr, QueryTask, Query, Expand, watchUtils, query, aspect, ClassBreaksRenderer, sizeRendererCreator, dom) {


    // Create a symbol for drawing the point
  var markerSymbol = {
      type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
      color: [226, 119, 40]
  };
  var data = [{codigo: 1010, dado: 14}, 
              {codigo: 1340, dado: 33}, 
              {codigo: 17696, dado: 1}, 
              {codigo: 1592, dado: 20}, 
              {codigo: 2014, dado: 15}, 
              {codigo: 4230, dado: 7}, 
              {codigo: 4327, dado: 16}, 
              {codigo: 4437, dado: 5}, 
              {codigo: 4523, dado: 2}, 
              {codigo: 7944, dado: 3}, 
              {codigo: 8830, dado: 3}, 
  ];

  var graphics = [
    {
      geometry: new Point({ x: -72.30655215634803, y: -7.233440155154325  }),
      attributes: { POCO_CD_POCO: 1010, POCO_MD_MERID_CENT: 0},
      symbol: markerSymbol,
    },
    {
      geometry: new Point({  x: -72.6467935804119, y: -7.726901040222517  }),
      attributes: {  POCO_CD_POCO: 1340, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.09255054418475, y: -7.111556189561019  }),
      attributes: {  POCO_CD_POCO: 17696, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.27245219393635, y: -8.243981691686791  }),
      attributes: {  POCO_CD_POCO: 1592, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -70.98258448074469, y: -9.297949065896336  }),
      attributes: {  POCO_CD_POCO: 2014, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.10704864513373, y: -6.252231583958221  }),
      attributes: {  POCO_CD_POCO: 4230, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.19535183859742, y: -6.8038134011091  }),
      attributes: {  POCO_CD_POCO: 4327, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.15125764622442, y: -6.923767446388189  }),
      attributes: {  POCO_CD_POCO: 4437, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.16845516737362, y: -7.5274621177233  }),
      attributes: {  POCO_CD_POCO: 4523, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.21974991787465, y: -8.042874908954616  }),
      attributes: {  POCO_CD_POCO: 7944, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    },
    {
      geometry: new Point({  x: -73.37676954276913, y: -8.179212397602045 }),
      attributes: {  POCO_CD_POCO: 8830, POCO_MD_MERID_CENT: 0 },
      symbol: markerSymbol
    }];

    const mainLayer = new FeatureLayer({
      source: graphics,
      id: "mainLayer",
      fields: [{
        name: "POCO_CD_POCO",
        alias: "POCO_CD_POCO",
        type: "oid"
      }, {
        name: "POCO_MD_MERID_CENT",
        alias: "POCO_MD_MERID_CENT",
        type: "integer"
      }],
      objectIdField: "POCO_CD_POCO",
      geometryType: "point"
    });

    const map = new Map({
      basemap: "gray",
      layers: [mainLayer]
    });

    const view = new MapView({
      container: "viewDiv",
      center : [ -57.45, -15.00 ],
      zoom : 4,
      map: map
    });


    let featureLayer, graphic, min, max;
    var arrayTotais = [];
    
    //DUPLICANDO A CAMADA DE POCOS, REFAZENDO O FILTRO
    view.map.findLayerById("mainLayer").load()
    .then((layer) => {
      return layer.queryFeatures({
        where: "1=1",
        returnGeometry: true,
        outFields: ["*"]
      })
      .then((featureSet) => {
        //COLOCANDO TODOS OS DADOS DA CAMADA POCOS NESSA NOVA CAMADA
        featureLayer = new FeatureLayer({
          id: "secondLayer",
          source: featureSet.features,
          fields: layer.fields,
          renderer: layer.renderer,
          listMode: "hide",
          title: "Second Layer",
          spatialReference: {
            wkid: 102100
          },
          outFields: ["*"]
        });
        return featureLayer.load();
      });
    })
    .then((layer) => addLayer(layer));

    function addLayer(layer) {
      //ADD A CAMADA NO MAPA
      featureLayer = layer;
      map.add(layer);

      //ITERA POR TODOS OS POCOS E SUBSTITUI O VALOR DE UMA VARIAVEL PELO VALOR DO TOTAL QUE EU PRECISO
      //PRA GERAR O MAPA DE DISTRIBUICAO
      featureLayer.queryFeatures({
        where: "1=1",
        returnGeometry: true,
        outFields: ["*"]
      })
      .then((featureSet) => {
        arr.forEach(featureSet.features, function(feature) {
          arr.forEach(data, function (poco) {
            if(poco.codigo === feature.attributes.POCO_CD_POCO) {
              feature.attributes.POCO_MD_MERID_CENT = poco.dado;
            }
          });
          var edits = {
              updateFeatures: [feature]
          };
          featureLayer.applyEdits(edits); 
        });

        var info = [{
          minValue: 1,
          maxValue: 9,
          label: "1-9",
          symbol: {
            type: "simple-marker",  
            style: "circle",
            color: "red",
            size: 10,  // pixels
            outline: {
              color: "white"
            }
          }
        }, {
          minValue: 10,
          maxValue: 18,
          label: "10-18",
          symbol: {
            type: "simple-marker",  
            style: "circle",
            color: "red",
            size: 15,  // pixels
            outline: {
              color: "white"
            }
          }
        },{
          minValue: 19,
          maxValue: 27,
          label: "19-27",
          symbol: {
            type: "simple-marker",  
            style: "circle",
            color: "red",
            size: 20,  // pixels
            outline: {
              color: "white"
            }
          }
        },{
          minValue: 28,
          maxValue: 36,
          label: "28-36",
          symbol: {
            type: "simple-marker",  
            style: "circle",
            color: "red",
            size: 20,  // pixels
            outline: {
              color: "white"
            }
          }
        }];

        //ALTERA O RENDERER DA CAMADA PARA AS BOLINHAS
        var renderer = {
            type: "class-breaks",  // autocasts as new ClassBreaksRenderer()
            field: "POCO_MD_MERID_CENT",
            classBreakInfos: info
        };

        featureLayer.renderer = renderer;

        const legend = new Legend({
          view: view
        });

        view.ui.add(legend, "bottom-right");

      });
    }

    function applyEdits(params) {
      var promise = featureLayer.applyEdits(params);
      editResultsHandler(promise);
    }

  const print = new Print({
    view: view,
    // specify your own print service
    printServiceUrl:
      "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
  });

  // Adds widget below other elements in the top left corner of the view
  view.ui.add(print, {
    position: "top-left"
  });


}); //end require



</script>
</head>

<body>
<div id="viewDiv"></div>
</body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console