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"
    />
    <title>Filter on hover</title>

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


      .esri-feature {
        letter-spacing: 0em;
        font-family: "Avenir Next", "Helvetica Neue", sans-serif;
        line-height: 1.55rem;
        font-feature-settings: "liga"1, "calt"0;
        background: #fff;
        padding: 1em;
      }
    </style>

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

    <script>
      require([
        "esri/Map",
        "esri/layers/GeoJSONLayer",
        "esri/views/MapView",
        "esri/core/watchUtils",
        "esri/widgets/Feature",
        "@dojo/framework/core/util"
      ], function(Map, GeoJSONLayer, MapView, watchUtils, Feature, util) {
        // If GeoJSON files are not on the same domain as your website, a CORS enabled server
        // or a proxy is required.
        const url =
          "https://raw.githubusercontent.com/ebrelsford/geojson-examples/master/nyc_council_districts.geojson";

        const template = {
          title: "NYC Council Districys",
          content: "Council Distrcit {CounDist}"
        };

        const geojsonLayer = new GeoJSONLayer({
          url: url,
          popupTemplate: template,
          outFields: ["*"]
        });

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

        const view = new MapView({
          container: "viewDiv",
          center: [-74.0060, 40.7128],
          zoom: 10,
          map: map
        });

        const graphic = {
          popupTemplate: {
            content: "Mouse over features to show details..."
          }
        };

        // Provide graphic to a new instance of a Feature widget
        const featureWidget = new Feature({
          graphic: graphic,
          view: view
        });

        view.ui.add(featureWidget, "top-right");

        view.when(() => {
          view.popup.highlightEnabled = false;
        });

        // Can apply filter functions as effects
        // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function
        view.whenLayerView(geojsonLayer).then(layerView => {
          watchUtils.whenFalseOnce(layerView, "updating", () => {
            view.on("pointer-move", util.debounce(event => {
              view.hitTest(event).then(result => {
                if (!result.results.length) {
                  featureWidget.graphic = graphic;
                  layerView.effect = null;
                  return;
                }
                const feature = result.results[0].graphic;
                if (!feature.attributes.CounDist) {
                  return;
                }
                featureWidget.graphic = feature;
                layerView.effect = {
                  filter: {
                    where: `CounDist = ${feature.attributes.CounDist}`,
                    spatialRelationship: "intersect"
                  },
                  excludedEffect: "opacity(50%)"
                };
              });
            }));
          });
        });
      });
    </script>
  </head>

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

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console