Select to view content in your preferred language

Feature Layer Not Showing

1819
2
Jump to solution
03-02-2018 08:19 AM
GregoryPierce
New Contributor II

Hi,

I've just started with the JavaScript API and I'm trying to add a feature layer per the examples I've found on the API page, but for some reason I am not able to see the layer in the map.  My sample code is below.  Any help trouble shooting this is appreciated.  Thank you.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer - 4.6</title>

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

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

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

<script>
require(["esri/Map", "esri/views/MapView", "dojo/domReady!", "esri/layers/FeatureLayer"],
function (Map, MapView, FeatureLayer)
{
var map = new Map({basemap: "hybrid"});

var view = new MapView({
container: "viewDiv",
map: map,
zoom: 11,
center: [-111.99, 41.05] // longitude, latitude
});

const fl = new FeatureLayer({
url: "http://arcgis.weberbasin.net/arcgiswa/rest/services/CurrentServiceAreas/FeatureServer/0"
});

map.add(fl);
});
</script>


</head>

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

</html>

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Gregory,


  Your require array is in the wrong order.


require(["esri/Map", "esri/views/MapView", "dojo/domReady!", "esri/layers/FeatureLayer"], 

Should be:

require(["esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer", "dojo/domReady!"], 

Notice FeatureLayer is before domReady

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Gregory,


  Your require array is in the wrong order.


require(["esri/Map", "esri/views/MapView", "dojo/domReady!", "esri/layers/FeatureLayer"], 

Should be:

require(["esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer", "dojo/domReady!"], 

Notice FeatureLayer is before domReady

0 Kudos
GregoryPierce
New Contributor II

Awesome!  Thanks so much!

0 Kudos