I have tried to follow the example at https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/index.html
The first issue I have is that I am not using any URL to get my data. I have a .cshtml page and my data is stored in my ViewBag, which I store in a script variable.
<script>
var data = [{"MAST_REL":"704834405041S00676","XCoordinate":-95.455847,"YCoordinate":29.912856},{"MAST_REL":"706050261041C40974","XCoordinate":-95.465469,"YCoordinate":30.074337}];
</script>
Secondly, I get an error message: Object doesn't support property or method 'then' which is thrown from the createGraphics method. My abbreviated code:
view.then(function() {
createGraphics()
.then(createLayer) // when graphics are created, create the layer
.otherwise(errback);
});
function createGraphics() {
debugger;
// Create an array of Graphics from each GeoJSON feature
return data.map(function(feature, i) {
return {
geometry: new Point({
x: feature.XCoordinate,
y: feature.YCoordinate
}),
// select only the attributes you care about
attributes: {
ObjectID: i,
//title: feature.properties.title,
//type: feature.properties.type,
//place: feature.properties.place,
//depth: feature.geometry.coordinates[2] + " km",
//time: feature.properties.time,
//mag: feature.properties.mag,
//mmi: feature.properties.mmi,
//felt: feature.properties.felt,
//sig: feature.properties.sig,
//url: feature.properties.url
}
};
});
}
The last couple of issues. I am not familiar with JavaScript nor the GIS ESRI Api. Thanks. Also, the "Source Code" button is not working or I don't know how to use that either. I'd think you would highlight the source code and select it.