---
title: Zoom to all features
description: Fitting the map to the boundaries of all features in the layer by querying the service. More information about Feature Layers can be found in the <a href="../api-reference/layers/feature-layer.html">L.esri.FeatureLayer</a> documentation.
layout: example.hbs
---

<div id="map"></div>

<script>
  var map = L.map('map').setView([45.526, -122.667], 5);

  L.esri.basemapLayer('Streets').addTo(map);

  var trees = L.esri.featureLayer({
    url: 'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Heritage_Trees_Portland/FeatureServer/0'
  }).addTo(map);

  trees.query().bounds(function (error, latlngbounds) {
    map.fitBounds(latlngbounds);
  });
</script>

---
title: Zoom to all features
description: Fitting the map to the boundaries of all features in the layer by querying the service. More information about Feature Layers can be found in the <a href="../api-reference/layers/feature-layer.html">L.esri.FeatureLayer</a> documentation.
layout: example.hbs
---

<div id="map"></div>

<script>
  var map = L.map('map').setView([34.33, -118.50], 5);

  L.esri.basemapLayer('Streets').addTo(map);

  var trails = L.esri.featureLayer({
    url: 'https://public.gis.lacounty.gov/public/rest/services/LACounty_Dynamic/LMS_Data_Public/MapServer/18'
  }).addTo(map);

  trails.query().bounds(function (error, latlngbounds) {
    map.fitBounds(latlngbounds);
  });
</script>

Update example using LA County (CA) open data
Update example using LA County (CA) open data
