Hide Table of Contents
View Basic clustering sample in sandbox
Basic clustering


This sample demonstrates how to enable featureReduction (e.g. clustering) on a FeatureLayer. This is handled via the featureReduction constructor option, or the setFeatureReduction() method.

Support for feature reduction is limited to the following scenarios:

  • The map must have a spatial reference of Web Mercator or WGS84.
  • FeatureLayer or CSVLayer with point geometries fewer than 50,000 features.
  • FeatureLayer created from a service URL must point to a service that supports pagination.
  • When editing is initiated with the Editor widget, then feature reduction is disabled until the Editor widget is destroyed.


<!DOCTYPE html>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
<title>Basic clustering on FeatureLayer</title>

<link rel="stylesheet" href="https://js.arcgis.com/3.46/esri/css/esri.css">
<script src="https://js.arcgis.com/3.46/"></script>

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

    top: 0px;
    right: 0px;
    position: absolute;
    z-index: 2;
    opacity: 0.9;
    background-color: whitesmoke;
    padding: 8px;
    font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-size: 12px;

  ], function(Map, FeatureLayer, PopupTemplate, Legend
  ) {

    var map = new Map("viewDiv", {
      basemap: "dark-gray-vector",
      center: [ -73.92872, 40.71321 ],
      zoom: 11

    // Enable clustering in the layer's constructor
    // and add the layer to the map

    var serviceUrl = "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/nyc_parks_gardens_hist_sites/FeatureServer/0";
    var layer = new FeatureLayer(serviceUrl, {
      outFields: [ "facname", "proptype", "factype", "address" ],
      featureReduction: {
        type: "cluster"
      infoTemplate: new PopupTemplate({
        title: "{facname}",
        description: "{proptype} {factype} on {address}."

    map.on("load", function(evt){
      var legend = new Legend({
        map: map,
        layerInfos: [{
          layer: layer,
          title: "Parks and historic sites"
      }, "legendDiv");




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

Show Modal