Dear all,
I am trying to update the code for loading GeoJSON available in here and I am having some issue while creating the FeatureLayer.
The original code 1 (ArcGIS 3.10compact) was changed to code 2 (ArcGIS 4.10, but the response while checking the console.log are not the same for both codes. Could someone point me what is going wrong? Why the response are not the same? has the code has already been updated to ArcGIS API 4.10 version?
I appreciated your time
Kind regards
Julierme
Code 1
// Create a feature layer for the GeoJSON
function addGeoJSONLayer(geojson) {
if (!geojson.features.length) {
return;
}
removeGeoJSONLayer();
// Get geometry type - assume same geometry for entire file!
var esriGeometryType = getEsriGeometryType(geojson.features[0].geometry.type);
// Create an skeleton collection and popup definition
var featureCollection = createFeatureCollection(esriGeometryType);
console.log("I am featureCollection: ", featureCollection);
// Display all the attributes from the GeoJSON in the Popup
var infoTemplate = new InfoTemplate("Julierme GeoJSON Data", "${*}");
// Display only specific attributes in from the GeoJSON file in the Popup
// var infoTemplate = new InfoTemplate("Julierme GeoJSON Data", "Country: ${OBJECTID}<br>Name: ${name}");
// Create feature layer
featureLayer = new FeatureLayer(featureCollection, {
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"],
infoTemplate: infoTemplate
});
console.log("This is featureLayer: ", featureLayer);
Code 2
featureLayer = new FeatureLayer({
source: featureCollection,
outFields: ["*"],
popupTemplate: template
});
console.log("I am featureLayer: ",featureLayer);
Mapping Examples