Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 3.95 KB

File metadata and controls

62 lines (46 loc) · 3.95 KB

###Add a feature layer to a map

In this lab you will add a feature layer to an ArcGIS API for JavaScript application.

  1. Click create_starter_map/index.html and copy the contents to a new jsbin.com.

  2. In JSBin > HTML, update the require statement and function definition:

require([
  "esri/Map",
  "esri/views/MapView",
  /*** ADD ***/
  "esri/layers/FeatureLayer",
  "dojo/domReady!"
], function(Map, MapView, FeatureLayer) {
  1. Now add the NYC Metro Lines to the map by assigning the REST endpoint url of the layer.
  ...

  /*** ADD ***/

  var metrolines = new FeatureLayer({
    url: "https://services.arcgis.com/bGgB6gXiQ835YdNp/arcgis/rest/services/NYC_SubwayLines/FeatureServer/1"
  });

  map.add(metrolines);
  1. Confirm that the JSBin Output panel shows a map with rail lines.

Your app should look something like this:

###Bonus

  metroStationsFL.watch("loadStatus", function(status) {
        // status types not-loaded, loading, loaded, failed
        console.log("'" + metroStationsFL.title + "'" + " " + status);
        if (status === "failed") {
            console.log(poi.loadError);
  }
  • The 4.x JS API works closely with ArcGIS Portals. Instead of the Feature Service URL, use the Portal Item ID to add layers. See the URLs of the Portal Items for Stations, Lines and BlockGroups to get their IDs. Here is the code.. What functionality do you gain in the app automatically when using the Portal Id's vs adding the feature layer using the url?