Book Image

Leaflet.js Essentials

By : Paul Crickard III, Paul Crickard
Book Image

Leaflet.js Essentials

By: Paul Crickard III, Paul Crickard

Overview of this book

Table of Contents (13 chapters)
Leaflet.js Essentials
About the Author
About the Reviewers

Query by attribute

When consuming a service, you usually load the entire layer. Sometimes, you may only want a subset of the layer data. Using a query will allow you to load only that subset that you are interested in. In this example, you will query a graffiti layer for open and closed cases. To create the map, follow these steps:

  1. Reference the Esri-leaflet file as you have seen in the previous examples. You do not need any additional files. Style the <div> query using CSS:

      #query {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 10;
        background: white;
        padding: 1em;
      #query select {
        font-size: 16px;
  2. Create the selection element and add Open and Closed as options:

      <select id="caseStatus">
        <option value=''>Clear Screen</option>
        <option value='Open'>Open</option>
        <option value='Closed'>Closed</option>
  3. Add...