UMD JS API Workshop
Exercise 5 - Style a layer popup

Exercise:

In this lab, you will use code to style a popup.

1. Update the require statement and function definition to add PopupTemplate and the Legend widget.



require([
  "esri/Map",
  "esri/views/MapView",
  "esri/layers/FeatureLayer",
  "esri/symbols/SimpleLineSymbol",
  "esri/renderers/UniqueValueRenderer",
  "esri/PopupTemplate",
  "esri/widgets/Legend"
], function(Map, MapView, FeatureLayer, SimpleLineSymbol, UniqueValueRenderer, PopupTemplate, Legend) {


2. Now add a new PopupTemplate to the Waterfalls Feature Layer with the popup template style desired, in this case the Waterfalls layer has a field that contains information to be used in the popup:

var popupTemplate = new PopupTemplate({
  title: "{Name}",
  content: [{
    type: "text",
    text: "{PopupInfo}"
  }]
});


3. Now add the template to its assigned Feature Layer and add the Feature Layer to the map.

 var waterfalls = new FeatureLayer({
   url: "https://services.arcgis.com/hRUr1F8lE8Jq2uJo/arcgis/rest/services/Waterfalls/FeatureServer/0",
   popupTemplate: popupTemplate
 });



If you're stuck, ensure that your code looks like the solution in the picture below:




Challenges:

Add a legend and add it to the UI in your preferred location:



Final Solution