Feature Layer will not show

741
10
Jump to solution
05-01-2020 10:35 PM
CodyHilton
New Contributor II

Hi, I currently cannot get the feature layer to load at the moment. Any help is appreciated. 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>Intro to MapView - Create a 2D map</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.15/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.15/"></script>
<script>
require(["esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
], function(Map, MapView, FeatureLayer) {

var map = new Map({
basemap: "streets"
});
var view = new MapView({
container: "viewDiv", // Reference to the scene div created in step 5
map: map, // Reference to the map object created before the scene
zoom: 11, // Sets zoom level based on level of detail (LOD)
center: [282.9, 38.9] // Sets center point of view using longitude,latitude
});

var publicschoolsLayer = new FeatureLayer({
url: "https://services1.arcgis.com/MiBZ4u97DWldovjI/arcgis/rest/services/schools_services/FeatureServer/0/query?outFields=*&where=1%3D1"
});


});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>

0 Kudos
1 Solution

Accepted Solutions
VictorCoelho
New Contributor III

Here's my code:

var publicschoolsLayer = new FeatureLayer({
url: "https://services1.arcgis.com/MiBZ4u97DWldovjI/arcgis/rest/services/schools_services/FeatureServer/0/"
});

map.add(publicschoolsLayer);

View solution in original post

0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Cody,

  Drop the "/query?outFields=*&where=1%3D1" from your url and you will be good to go.

CodyHilton
New Contributor II

I tried that but it did not work. I believe it could be because I do not have access to it. I thought I set up the server connection correct but I believe I did not at this point. 

0 Kudos
VictorCoelho
New Contributor III

Hi Cody,

I was able to make it work. Just need to drop the filter as Robert mentioned above and add the Feature layer to the map:

ArcGIS API for JavaScript Sandbox 

0 Kudos
VictorCoelho
New Contributor III

The Schools are located in Florida, your cod is centering the map in a different area:  

CodyHilton
New Contributor II

okay, ill try again, I had it centered differently cause I was looking at different data trying to decide

0 Kudos
CodyHilton
New Contributor II

I still cannot get it to load, I am not sure why. If you were able to load then the rest of the code should be fine. 

0 Kudos
VictorCoelho
New Contributor III

Here's my code:

var publicschoolsLayer = new FeatureLayer({
url: "https://services1.arcgis.com/MiBZ4u97DWldovjI/arcgis/rest/services/schools_services/FeatureServer/0/"
});

map.add(publicschoolsLayer);
0 Kudos
CodyHilton
New Contributor II

It worked now, I was missing a line of code I forgot is needed, thank you

0 Kudos
CodyHilton
New Contributor II

Thank you for the help. 

0 Kudos