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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

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

              
            
!

CSS

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

JS

              
                // Example of using the Search widget to match autocomplet only at the BEGINNING of the field
// (not anywhere in the scring)
// https://gis.stackexchange.com/questions/304300/esri-search-widget-alter-search-parameters-arcgis-js-v4-9
require([
  "esri/Map",
  "esri/views/SceneView",
  "esri/views/MapView",
  "esri/widgets/Search",
  "esri/tasks/Locator",
  "esri/layers/FeatureLayer",
  "esri/config",
  "dojo/domReady!"
], function(
  Map,
  SceneView,
  MapView,
  Search,
  Locator,
  FeatureLayer,
  esriConfig
) {
  var map = new Map({
    basemap: "streets"
  });

  var viewOptions = {
    container: "viewDiv",
    map: map,
    center: [-121.967522, 37.777081],
    zoom: 11
  };

  // 2D:
  // var view = new MapView(viewOptions);

  // 3D:
  var view = new SceneView(viewOptions);

  var searchWidget = new Search({
    view: view,
    includeDefaultSources: false,
    sources: [
      {
        featureLayer: new FeatureLayer({
          url:
            "https://ccmap.cccounty.us/arcgis/rest/services/LUCA/LUCA_ADDRESS/FeatureServer/0",
          outFields: ["*"]
        }),
        searchFields: ["full_address"],
        displayField: "full_address",
        exactMatch: false,
        outFields: ["*"],
        name: "Addresses",
        placeholder: "Try typing '123' here",
        maxResults: 6,
        maxSuggestions: 6,
        suggestionsEnabled: true,
        minSuggestCharacters: 0
      }
    ]
  });

  // Add the search widget to the top right corner of the view
  view.ui.add(searchWidget, {
    position: "top-right"
  });

  esriConfig.request.interceptors.push({
    // set the `urls` property to the URL of the FeatureLayer so that this
    // interceptor only applies to requests made to the FeatureLayer URL
    urls: "https://ccmap.cccounty.us/arcgis/rest/services/LUCA/LUCA_ADDRESS/FeatureServer/0",
    // use the BeforeInterceptorCallback to check if the query of the
    // FeatureLayer has a where property set.
    // if so, then modify the "where" property how we want it to be.
    before: function(params) {
      if (params.requestOptions.query.where) {
        params.requestOptions.query.where = params.requestOptions.query.where.replace(
          "'%",
          "'"
        );
      }
    }
  });
});

              
            
!
999px

Console