###Add a feature layer to a map
In this lab you will add a feature layer to an ArcGIS API for JavaScript application.
Click create_starter_map/index.html and copy the contents to a new jsbin.com.
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) {
...
/*** ADD ***/
var featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/PDX_Rail_Lines_Styled/FeatureServer/0"
});
map.add(featureLayer);
Output
panel shows a map with rail lines.Your app should look something like this:
###Bonus
add()
method, try the addMany()
method instead. Read up on the layers
collection and see how the API gives you a few ways to add layers to a map.