Hide Table of Contents
View Feature Layer (basic) sample in sandbox
Feature Layer (basic)

Description

This sample demonstrates how to add a basic feature layer to a map. At a minimum, the FeatureLayer must point to a valid feature service hosted on ArcGIS Server or ArcGIS Online or be constructed with a Feature Collection object. To learn more about feature services,read this documentation.

Code

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>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>

<style>
html, body, #map {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
}
</style>

<script>
require([
    "esri/map",
    "esri/layers/FeatureLayer",
    "dojo/domReady!"
  ],
  function(
    Map,
    FeatureLayer
  ) {

    var map = new Map("map", {
      basemap: "hybrid",
      center: [-82.44109, 35.6122],
      zoom: 17
    });

    /****************************************************************
     * Add feature layer - A FeatureLayer at minimum should point
     * to a URL to a feature service or point to a feature collection 
     * object.
     ***************************************************************/

    // Carbon storage of trees in Warren Wilson College.
    var featureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0");

    map.addLayer(featureLayer);

  });
</script>
</head>

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

</html>
 
          
Show Modal