I'm just a simple farmer tending to his ArcGIS online hosted feature layers. I pinpointed the problem as that I can't seem to properly create a FeatureLayer object based on a url to a hosted feature layer. I can execute query tasks and what not just fine, but I'm really not sure where I'm going wrong with creating a feature layer. I tried just using an esri example feature layer, and it's still not working for me. Am I just missing something dumb? Javascript API v3.31 btw
My code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>testfeatures</title>
<script src="https://js.arcgis.com/3.31/"></script>
<script>
require([
"dojo/_base/declare",
"dojo/dom",
"dojo/parser",
"dojo/ready",
"esri/layers/FeatureLayer"
], function(declare, dom, parser, ready, FeatureLayer) {
parser.parse();
ready(function() {
var testLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0", {
mode: FeatureLayer.MODE_AUTO,
outFields: ["*"]
});
console.log(testLayer);
console.log(testLayer.fields)
})
});
</script>
</head>
<body>
</body>
Console logging the fields gives "undefined", whereas logging the feature layer itself gives me an object.
Thanks for any help!