Feature Layer Apply Edits is not adding all graphics

123
1
Jump to solution
12-14-2022 07:22 AM
MarcoSotoDev
新的贡献者二世

Hello,

I am following the logic used to add large sets of graphics to the feature layer using an iterator and the apply edits function based on this sample

https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-large-collection/

It seems to work with large sets of data but when I try to add like 30 or 100 graphics using this method, only about 4 or so get plotted onto the map. I can confirm that its not a data issue of missing lat long coordinates. When I log the feature lengths that are added, they always add up correctly to the number of features that are supposed to display. They just never pop on map? Any help would be appreciated. Here is my code for adding graphics

let result = iterator.next(); while (!result.done) { const start = performance.now(); const features = []; // consume for batchTime milliseconds. while (performance.now() - start < batchTime && !result.done) { features.push(result.value); result = iterator.next(); console.log(features); } if (features.length) { console.log(`uploading ${features.length} features`); await vbLayer.applyEdits({ addFeatures: features, }); } }

I also will attach the iterator im using

* vbSitesGraphicIterator(allSites: Site[]){ for(let i = 0; i < allSites.length; i++){ let site = allSites[i]; let siteAttributes = { // OBJECTID: objectId++, Number: site.newSiteNo, Name: site.siteName, Address: site.addressLine1, City: site.city, State: site.stateProvince, ZipCode: site.postalCode, Category: site.siteCategory, Classification: site.legalStatus, Type: site.towerType, AGL: site.agl, AMSL: site.amsl, Latitude: site.latitude, Longitude: site.longitude } yield new Graphic({ geometry: new Point({latitude: site.latitude, longitude: site.longitude}), symbol: new PictureMarkerSymbol({ width: 10, height:10, url: environment.vbPin }), attributes: siteAttributes, popupTemplate: { title: "{Number}", content: [ { type: "fields", fieldInfos: [ { fieldName: "Name" }, { fieldName: "Address" }, { fieldName: "City" }, { fieldName: "State" }, { fieldName: "ZipCode" }, { fieldName: "Category" }, { fieldName: "Classification" }, { fieldName: "TenantLegalName" }, { fieldName: "LeaseNo" }, { fieldName: "IsAnchorSite" }, { fieldName: "NoAvailableMeters" }, { fieldName: "IsOurMeter" }, { fieldName: "Type" }, { fieldName: "AGL" }, { fieldName: "AMSL" }, { fieldName: "Latitude" }, { fieldName: "Longitude" }, ] } ]} }); } }
0Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor II

I changed the values in the sample to load in 30 and less features and it worked ok. Do you have a codepen showing the issue with your data?

That samples shows how to batch applyEdits with a large amount of features so you don't block map interactions. With smaller datasets, you can probably get away without needing to batch the operation.

View solution in original post

1 Reply
ReneRubalcava
Frequent Contributor II

I changed the values in the sample to load in 30 and less features and it worked ok. Do you have a codepen showing the issue with your data?

That samples shows how to batch applyEdits with a large amount of features so you don't block map interactions. With smaller datasets, you can probably get away without needing to batch the operation.