AnsweredAssumed Answered

How to display a feature layer

Question asked by skerdreux on Aug 21, 2018
Latest reply on Aug 22, 2018 by rscheitlin

Hello,

 

I'm new in javascript development and I try to do something very simple : 

Display a featureLayer.

 

Here my code : 

 

<html>
<head>
<link rel="stylesheet" href="https://js.arcgis.com/4.8/esri/css/main.css">
<script src="https://js.arcgis.com/4.8/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"dojo/domReady!"
], function(Map, MapView,FeatureLayer) {

var layerRoute = new FeatureLayer({
id: "route",
opacity:0.8
});

layerRoute.when(function() {
view.goTo(layerRoute.fullExtent);
});

 

var map = new Map({
basemap: "streets",
layers: [layerRoute]
});

 

var view = new MapView({
container: "viewDiv",
map: map,
zoom: 4
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>

 

It should works but I had an error : 

 

dojo-lite.js:171 GET https://roadsandhighwayssample.esri.com/arcgis/rest/services/RoadsHighways/NewYork/MapServer/3?f=json&callback=dojo_request_script_callbacks.dojo_request_script0 0 ()

[esri.layers.FeatureLayer] #load() Failed to load layer (title: 'NewYork', id: 'route') h {name: "request:server", message: "Error loading https://roadsandhighwayssample.esri.…ojo_request_script_callbacks.dojo_request_script0", details: {…}}

 

I have no idea why it's not working. 

 

Is there anybody who can help me on this?

Outcomes