Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Leaflet.js Essentials

You're reading from   Leaflet.js Essentials Create interactive, mobile-friendly mapping applications using the incredibly light yet powerful Leaflet.js platform.

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher
ISBN-13 9781783554812
Length 180 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

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:

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

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

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image