cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="viewDiv"></div>
<div id="infoDiv">
  <div id="legendDiv"></div>
</div>
            
          
!
            
              html,
body,
#viewDiv {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

#infoDiv {
  top: 0px;
  right: 0px;
  position: absolute;
  z-index: 2;
  opacity: 0.9;
  background-color: whitesmoke;
  padding: 8px;
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
}

            
          
!
            
              require([
  "esri/arcgis/utils",
  "esri/Color",
  "esri/map",
  "esri/graphic",
  "esri/layers/GraphicsLayer",
  "esri/layers/FeatureLayer",
  "esri/dijit/PopupTemplate",
  "esri/dijit/Legend",
  "esri/symbols/SimpleFillSymbol",
  "esri/symbols/SimpleMarkerSymbol",
  "esri/symbols/SimpleLineSymbol",
  "esri/geometry/geometryEngine",
  "esri/geometry/Multipoint"
], function(
  arcgisUtils,
  Color,
  Map,
  Graphic,
  GraphicsLayer,
  FeatureLayer,
  PopupTemplate,
  Legend,
  SimpleFillSymbol,
  SimpleMarkerSymbol,
  SimpleLineSymbol,
  geometryEngine,
  Multipoint
) {
  const cvhLayer = new GraphicsLayer();

  const pline = new SimpleLineSymbol();
  pline.setColor(new Color([255, 255, 255, 1]));
  const fill = new SimpleFillSymbol();
  fill.setOutline(pline);
  fill.setColor(new Color([0, 197, 255, 0.25]));

  const line = new SimpleLineSymbol();
  line.setColor(new Color([0, 255, 255, 0.25]));

  const marker = new SimpleMarkerSymbol();
  marker.setOutline(line);
  marker.setColor(new Color([0, 92, 230, 1]));
  marker.setSize(8);
  arcgisUtils
    .createMap("ffcb9c2836a0484595ca59e32a0d549f", "viewDiv")
    .then(({ map }) => {
      const layerId = map.graphicsLayerIds[0];
      const layer = map.getLayer(layerId);

      map.addLayer(cvhLayer, 0);

      layer.on("mouse-over", ({ graphic }) => {
        cvhLayer.clear();
        if (graphic.isAggregate()) {
          const graphics = graphic.getChildGraphics();
          const geoms = graphics.map(x => x.geometry);
          const multiPoints = geometryEngine.union(geoms);
          //const cvh = geometryEngine.convexHull(multiPoints);
          //const cvhGraphic = new Graphic(cvh, fill);
          const g = new Graphic(multiPoints, marker);
          cvhLayer.add(g);
          //cvhLayer.add(cvhGraphic);
        }
      });

      map.on("extent-change", () => {
        cvhLayer.clear();
      });

      const legend = new Legend(
        {
          map: map,
          layerInfos: [
            {
              layer: layer,
              title: "Voting Precincts 2008"
            }
          ]
        },
        "legendDiv"
      );

      legend.startup();
    })
    .otherwise(error => console.warn(error));
});

            
          
!
999px
Loading ..................

Console