Load GeoJSON QuickStart Map API 4.10

02-27-2019 05:31 AM
New Contributor III

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


Code 1

// Create a feature layer for the GeoJSON
function addGeoJSONLayer(geojson) {
if (!geojson.features.length) {
// 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 

0 Kudos
1 Reply
New Contributor II

Hi Julierme,

Please review our example showing the creation of a feature layer from GeoJSON using our 4.x API.  Create a FeatureLayer with client side graphics | ArcGIS API for JavaScript 4.10 

There are a many changes between the 3.x and 4.x API versions and you may have to make changes to your code throughout as the API coding patterns have changed.  Again, please review the sample and modify your code as needed to match the patterns used in the 4.x API.