FeatureLayer | API Reference | ArcGIS API for JavaScript 4.24

文章推薦指數: 80 %
投票人數:10人

A FeatureLayer is a single layer that can be created from a Map Service or Feature Service; ArcGIS Online or ArcGIS Enterprise portal items; or from an array of ... ArcGISAPIforJavaScriptAPIReferenceOverviewSampleCodeAPIReferenceShowcaseBlogMenuesriesri/analysisesri/coreesri/formesri/geometryesri/identityesri/layersBaseDynamicLayerBaseElevationLayerBaseTileLayerBingMapsLayerBuildingSceneLayerCSVLayerElevationLayerFeatureLayerGeoJSONLayerGeoRSSLayerGraphicsLayerGroupLayerImageryLayerImageryTileLayerIntegratedMeshLayerKMLLayerLayerLineOfSightLayerMapImageLayerMapNotesLayerMediaLayerOGCFeatureLayerOpenStreetMapLayerPointCloudLayerRouteLayerSceneLayerStreamLayerSubtypeGroupLayerTileLayerUnknownLayerUnsupportedLayerVectorTileLayerVoxelLayerWCSLayerWebTileLayerWFSLayerWMSLayerWMTSLayerbuildingSublayersogcpointCloudFilterssupportesri/networksesri/popupesri/portalesri/renderersesri/restesri/smartMappingesri/supportesri/symbolsesri/viewsesri/webdocesri/webmapesri/websceneesri/widgetsReferenceNavigationMenuFeatureLayer Overview CreatingaFeatureLayer Querying DataVisualization Overview AFeatureLayerisasinglelayerthatcanbecreatedfroma MapService orFeatureService; ArcGISOnlineorArcGISEnterpriseportalitems;orfromanarrayofclient-sidefeatures.Thelayercanbeeithera spatial(hasgeographicfeatures)ornon-spatial(table). Spatiallayeriscomposedofdiscretefeatures,eachofwhichhasaGeometry thatallowsittoberenderedineithera2DMapViewor 3DSceneViewasa graphicwithspatialcontext.Featuresalsocontaindata attributesthatprovideadditionalinformationabout thereal-worldfeatureitrepresents;attributesmaybeviewedinpopupwindows andusedforrenderingthelayer. FeatureLayersmaybequeried,analyzed, andrenderedtovisualizedatainaspatialcontext. Non-spatiallayerisatablewhichdoesnothaveaspatialcolumnrepresentinggeographicfeatures. CreatingaFeatureLayer FeatureLayersmaybecreatedinoneofthreeways:fromaserviceURL,anArcGISportalitemID, orfromanarrayofclient-sidefeatures. ReferenceaserviceURL TocreateaFeatureLayerinstancefromaservice,youmustsettheurlproperty totheRESTendpointofalayerineitheraFeatureService oraMapService.Foralayertobevisibleinaview,itmustbeaddedtotheMap referencedbytheview.SeeMap.add()forinformationaboutaddinglayerstoamap. require(["esri/layers/FeatureLayer"],function(FeatureLayer){ //pointstothestateslayerinaservicestoringU.S.censusdata constfl=newFeatureLayer({ url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3" }); map.add(fl);//addsthelayertothemap }); Non-spatialtableinstancecanbecreatedfromthetableurlinaserviceandthetablemustbeloadedbycallingload() method. //Addanon-spatialtable. require(["esri/layers/FeatureLayer"],function(FeatureLayer){ //pointstothenon-spatialtableinaservicestoringSanFranciscocrimeincidents. consttable=newFeatureLayer({ url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1" }); table.load().then(function(){ //tableisloaded.readytobequeriedontheserver. }); }); Iftheserviceisrequestedfromadifferentdomain,aCORSenabledserveroraproxyis required. ReferenceanArcGISportalItemID YoucanalsocreateaFeatureLayerfromitsIDifitexistsasaniteminArcGISOnlineorArcGISEnterprise. Forexample,thefollowingsnippetshowshowtoaddanewFeatureLayerinstancetoamapusingthe portalItemproperty. //pointstoahostedFeatureLayerinArcGISOnline constfl=newFeatureLayer({ portalItem:{//autocastsasesri/portal/PortalItem id:"8444e275037549c1acab02d2626daaee" } }); map.add(fl);//addsthelayertothemap ThefollowingsnippetshowshowtocreateaFeatureLayerreferencingatableusingthe portalItemproperty. //pointstoahostedtableinArcGISOnline consttable=newFeatureLayer({ portalItem:{//autocastsasesri/portal/PortalItem id:"123f4410054b43d7a0bacc1533ceb8dc" } }); //Beforeaddingthetabletothemap,itmustfirstbeloadedandconfirmitistherighttype. table.load().then(function(){ if(table.isTable){ map.tables.add(table); } }); Addanarrayofclient-sidefeatures Beginningwithversion4.17,non-spatial,client-sidefeaturescanbeusedtocreatea featurelayertable. Client-sidefeaturesmayalsobeusedtocreateaFeatureLayer.SincetheFeatureLayerrequiresaschema,several propertiesneedtobesetwhencreatingalayerfromanarrayoffeatures.Ifworkingwith spatiallayers,thegeometrytypeofthefeaturesmustbeindicated(sinceonlyonegeometrytypeisallowedperlayer)using thegeometryTypepropertyalongwithavalidspatialreference.Bothspatialandnon-spatial featurecollectionsrequireanobjectIdfield,thismustbeindicatedalongwithan arrayoffieldobjects,providingtheschemaofeachfield.Oncethosepropertiesarespecified,the arrayoffeaturesmustbesettothesourceproperty.Checkout createaFeatureLayerwithclient-sidegraphicssampletosee thisinaction. Ifanyoftherequiredparametersaremissingatthetimeoflayerinitialization,theAPIwillattempttodeterminetherequiredparameters fromtheprovidedparameters.Forexample,thespatialReference,geometryType,hasZ andhasMpropertiescanbedeterminedbasedonthefeaturesprovidedtothesourceproperty. However,ifthesourcepropertyisanemptyarrayatthetimeofinitialization,thengeometryTypecannotbedeterminedandthe layerwillberejected. FeatureLayer'ssourceisnotupdatedaftertheFeatureLayerisinitialized.Iffeaturesareadded,removedorupdatedatruntime,thenuse applyEdits()toupdatethefeaturesthenusequeryFeatures()toreturnupdatedfeatures.Checkout addorremovegraphicsfromaFeatureLayersample toseethisinaction.Attributevaluesusedinattributequeriesexecutedagainstclient-sidefeaturelayer,andlayerviewsarecasesensitive. constlayer=newFeatureLayer({ //createaninstanceofesri/layers/support/Fieldforeachfieldobject fields:[ { name:"ObjectID", alias:"ObjectID", type:"oid" },{ name:"type", alias:"Type", type:"string" },{ name:"place", alias:"Place", type:"string" }], objectIdField:"ObjectID",//inferredfromfieldsarrayifnotspecified geometryType:"point",//geometryTypeandspatialReferenceareinferredfromthefirstfeature //inthesourcearrayiftheyarenotspecified. spatialReference:{wkid:4326}, source:graphics,//anarrayofgraphicswithgeometryandattributes //popupTemplateandsymbolarenotrequiredineachfeature //sincethosearehandledwiththepopupTemplateand //rendererpropertiesofthelayer popupTemplate:pTemplate, //adefaultsimplerendererwillbeappliedifnotset. renderer:uvRenderer//UniqueValueRendererbasedon`type`attribute }); map.add(layer); Querying FeatureswithinaFeatureLayerarerenderedasgraphicsinsidea LayerView.Thereforethefeaturesvisibleinaviewareaccessed viatheLayerView,nottheFeatureLayer.Toaccessfeaturesvisibleintheview,usethequerymethods intheFeatureLayerView. //returnsallthegraphicsfromthelayerview view.whenLayerView(layer).then(function(layerView){ layerView.watch("updating",function(val){ if(!val){//waitforthelayerviewtofinishupdating layerView.queryFeatures().then(function(results){ console.log(results);//printsalltheclient-sidefeaturestotheconsole }); } }); }); WhenaccessingfeaturesfromaqueryontheFeatureLayerView,notethat featuresarereturnedastheyaredisplayedintheview,includinganygeneralizationthatmayhavebeen appliedtothefeaturestoenhanceperformance.Toobtainfeaturegeometriesatfullresolution,use thequeryFeatures()methodontheFeatureLayer. ThequerymethodsintheFeatureLayerclassqueryfeaturesdirectlyfromtheservice. Forexample,thefollowingsnippetreturnsallfeaturesfromtheservice,notjustthefeaturesdrawninthe FeatureLayerView. //Queriesforallthefeaturesintheservice(notthegraphicsintheview) layer.queryFeatures().then(function(results){ //printsanarrayofallthefeaturesintheservicetotheconsole console.log(results.features); }); ForinformationregardinghowtocreateaLayerView foraparticularlayer,seeView.whenLayerView(). DataVisualization FeaturesinaFeatureLayerarevisualizedbysettingaRenderertothe rendererpropertyofthelayer.Featuresmaybevisualizedwiththesamesymbolusing SimpleRenderer,bytypewithUniqueValueRenderer, withclassbreaksusingClassBreaksRenderer,orwithcontinuouscolor,size,or opacityschemesusingvisualvariablesin anyoftherenderers.Symbolscanonlybesetthrougharendererandnotindividuallyoneachgraphicinthelayer. SeethedocumentationforRendererandthe Creatingvisualizationsmanuallyguideformoreinformation aboutthevariousvisualizationoptionsforFeatureLayers. UsingtheFeatureLayerrenderersandquerycapabilitiesmentionedabove,youcancreatedynamic,interactivedataexplorationapps. FeatureLayersalsosupporthighlight. Thisisenabledbydefaultwhenusersclickortapfeaturestoviewthepopup.Youcanalsocallthe highlight()methodonthe FeatureLayerViewtohighlightfeaturesinotherworkflows,suchasfordisplayingquery/selection resultsandhighlightingfeaturesonpointer-moveevents. KnownLimitations Locationswithaveryhighdensityoffeaturesmaynotdisplayallavailablefeaturesatsmallscales. Verylargedatasetsmayrequirepotentiallylonginitialloadtimes,particularlyatsmallscales. Server-sideandclient-sidefeaturetilecachingallowfeaturestoloadmuchfasteraftertheinitialdatadownload. Wearecontinuouslyimprovingourfeaturefetchingstrategyandloadtimeefficiencyineachrelease. Seealso: Sample-AddFeatureLayertoyourMap Sample-CreateaFeatureLayerwithclient-sidegraphics Sample-QueryfeaturesfromaFeatureLayer FeatureLayerView Constructors newFeatureLayer(properties) Parameter: properties Object optional Seethepropertiesforalistofalltheproperties thatmaybepassedintotheconstructor. Seealso: Client-sideFeatureLayer Example: //Typicalusage //Createfeaturelayerfromfeatureservice constlayer=newFeatureLayer({ //URLtotheservice url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0" }); //Typicalusage //Createfeaturelayerfromclient-sidegraphics constlayer=newFeatureLayer({ source:graphics, fields:[{ name:"ObjectID", alias:"ObjectID", type:"oid" },{ name:"place", alias:"Place", type:"string" }], objectIdField:"ObjectID", geometryType:"point" }); PropertyOverview Anypropertiescanbeset,retrievedorlistenedto.SeetheWorkingwithPropertiestopic. Showinheritedproperties Hideinheritedproperties Name Type Summary Class apiKeyStringmoredetailsAnauthorizationstringusedtoaccessaresourceorservice.moredetailsFeatureLayer blendModeStringmoredetailsBlendmodesareusedtoblendlayerstogethertocreateaninterestingeffectinalayer,oreventoproducewhatseemslikeanewlayer.moredetailsFeatureLayer capabilitiesObjectmoredetailsDescribesthelayer'ssupportedcapabilities.moredetailsFeatureLayer copyrightStringmoredetailsCopyrightinformationforthelayer.moredetailsFeatureLayer customParametersObjectmoredetailsAlistofcustomparametersappendedtotheURLofallresourcesfetchedbythelayer.moredetailsFeatureLayer datesInUnknownTimezoneBooleanmoredetailsThispropertyissetbytheservicepublisherandindicatesthatdatesshouldbeconsideredwithoutthelocaltimezone.moredetailsFeatureLayer declaredClassStringmoredetailsThenameoftheclass.moredetailsAccessor definitionExpressionStringmoredetailsTheSQLwhereclauseusedtofilterfeaturesontheclient.moredetailsFeatureLayer displayFieldStringmoredetailsThenameofthelayer'sprimarydisplayfield.moredetailsFeatureLayer dynamicDataSourceDynamicMapLayer|DynamicDataLayermoredetailsAnobjectthatallowsyoutocreateadynamiclayerwithdataeitherfrommapservicesublayersordatafromaregisteredworkspace.moredetailsFeatureLayer editFieldsInfoEditFieldsInfomoredetailsTheeditortrackingfields,whichrecordwhoaddsoreditsthedatathroughthefeatureserviceandwheneditsaremade.moredetailsFeatureLayer editingEnabledBooleanmoredetailsDeterminesifthelayeriseditable.moredetailsFeatureLayer editingInfoEditingInfomoredetailsIfpresent,thisvaluespecifiesinformationaboutediting.moredetailsFeatureLayer effectEffectmoredetailsEffectprovidesvariousfilterfunctionsthatcanbeperformedonthelayertoachievedifferentvisualeffectssimilartohowimagefilterswork.moredetailsFeatureLayer elevationInfoObjectmoredetailsSpecifieshowfeaturesareplacedontheverticalaxis(z).moredetailsFeatureLayer featureEffectFeatureEffectmoredetailsThefeatureEffectcanbeusedtodrawattentionfeaturesofinterest.moredetailsFeatureLayer featureReductionFeatureReductionBinning|FeatureReductionCluster|FeatureReductionSelectionmoredetailsConfiguresthemethodforreducingthenumberofpointfeaturesintheview.moredetailsFeatureLayer fieldsField[]moredetailsAnarrayoffieldsinthelayer.moredetailsFeatureLayer fieldsIndexFieldsIndexmoredetailsAconvenientpropertythatcanbeusedtomakecase-insensitivelookupsforafieldbyname.moredetailsFeatureLayer floorInfoLayerFloorInfomoredetailsWhenafeaturelayerisconfiguredasfloor-aware,ithasafloorInfopropertydefined.moredetailsFeatureLayer formTemplateFormTemplatemoredetailsThetemplateusedinanassociatedlayer'sFeatureForm.moredetailsFeatureLayer fullExtentExtentmoredetailsThefullextentofthelayer.moredetailsLayer gdbVersionStringmoredetailsTheversionofthegeodatabaseofthefeatureservicedata.moredetailsFeatureLayer geometryFieldsInfoGeometryFieldsInfomoredetailsProvidesinformationonthesystemmaintainedareaandlengthfieldsalongwiththeirrespectiveunits.moredetailsFeatureLayer geometryTypeStringmoredetailsThegeometrytypeoffeaturesinthelayer.moredetailsFeatureLayer hasMBooleanmoredetailsIndicateswhethertheclient-sidefeaturesinthelayerhaveM(measurement)values.moredetailsFeatureLayer hasZBooleanmoredetailsIndicateswhethertheclient-sidefeaturesinthelayerhaveZ(elevation)values.moredetailsFeatureLayer historicMomentDatemoredetailsThehistoricmomenttoquery.moredetailsFeatureLayer idStringmoredetailsTheuniqueIDassignedtothelayer.moredetailsLayer isTableBooleanmoredetailsReturnstrueifthelayerisloadedfromanon-spatialtableinaservice.moredetailsFeatureLayer labelingInfoLabelClass[]moredetailsThelabeldefinitionforthislayer,specifiedasanarrayofLabelClass.moredetailsFeatureLayer labelsVisibleBooleanmoredetailsIndicateswhethertodisplaylabelsforthislayer.moredetailsFeatureLayer layerIdNumbermoredetailsThelayerID,orlayerindex,ofaFeatureServicelayer.moredetailsFeatureLayer legendEnabledBooleanmoredetailsIndicateswhetherthelayerwillbeincludedinthelegend.moredetailsFeatureLayer listModeStringmoredetailsIndicateshowthelayershoulddisplayintheLayerListwidget.moredetailsLayer loadedBooleanmoredetailsIndicateswhetherthelayer'sresourceshaveloaded.moredetailsLayer loadErrorErrormoredetailsTheErrorobjectreturnedifanerroroccurredwhileloading.moredetailsLayer loadStatusStringmoredetailsRepresentsthestatusofaloadoperation.moredetailsLayer loadWarningsObject[]moredetailsAlistofwarningswhichoccurredwhileloading.moredetailsLayer maxScaleNumbermoredetailsThemaximumscale(mostzoomedin)atwhichthelayerisvisibleintheview.moredetailsFeatureLayer minScaleNumbermoredetailsTheminimumscale(mostzoomedout)atwhichthelayerisvisibleintheview.moredetailsFeatureLayer objectIdFieldStringmoredetailsThenameofanoidfieldcontainingauniquevalueoridentifierforeachfeatureinthelayer.moredetailsFeatureLayer opacityNumbermoredetailsTheopacityofthelayer.moredetailsLayer orderByObject[]moredetailsDeterminestheorderinwhichfeaturesaredrawnintheview.moredetailsFeatureLayer outFieldsString[]moredetailsAnarrayoffieldnamesfromtheservicetoincludewitheachfeature.moredetailsFeatureLayer popupEnabledBooleanmoredetailsIndicateswhethertodisplaypopupswhenfeaturesinthelayerareclicked.moredetailsFeatureLayer popupTemplatePopupTemplatemoredetailsThepopuptemplateforthelayer.moredetailsFeatureLayer portalItemPortalItemmoredetailsTheportalitemfromwhichthelayerisloaded.moredetailsFeatureLayer refreshIntervalNumbermoredetailsRefreshintervalofthelayerinminutes.moredetailsFeatureLayer relationshipsRelationship[]moredetailsArrayofrelationshipssetupforthelayer.moredetailsFeatureLayer rendererRenderermoredetailsTherendererassignedtothelayer.moredetailsFeatureLayer returnMBooleanmoredetailsWhentrue,indicatesthatMvalueswillbereturned.moredetailsFeatureLayer returnZBooleanmoredetailsWhentrue,indicatesthatz-valueswillalwaysbereturned.moredetailsFeatureLayer screenSizePerspectiveEnabledBooleanmoredetailsApplyperspectivescalingtoscreen-sizepointsymbolsinaSceneView.moredetailsFeatureLayer serviceDefinitionExpressionStringmoredetailsTheservicedefinitionexpressionlimitsthefeaturesavailablefordisplayandquery.moredetailsFeatureLayer sourceCollectionmoredetailsAcollectionofGraphicobjectsusedtocreateaFeatureLayer.moredetailsFeatureLayer sourceJSONObjectmoredetailsThefeatureservice'smetadataJSONexposedbytheArcGISRESTAPI.moredetailsFeatureLayer spatialReferenceSpatialReferencemoredetailsThespatialreferenceofthelayer.moredetailsFeatureLayer templatesFeatureTemplate[]moredetailsAnarrayoffeaturetemplatesdefinedinthefeaturelayer.moredetailsFeatureLayer timeExtentTimeExtentmoredetailsThelayer'stimeextent.moredetailsFeatureLayer timeInfoTimeInfomoredetailsTimeInfoprovidesinformationsuchasdatefieldsthatstorestartandendtimeforeachfeatureandthefullTimeExtentforthelayer.moredetailsFeatureLayer timeOffsetTimeIntervalmoredetailsAtemporaryoffsetofthetimedatabasedonacertainTimeInterval.moredetailsFeatureLayer titleStringmoredetailsThetitleofthelayerusedtoidentifyitinplacessuchastheLegendandLayerListwidgets.moredetailsFeatureLayer typeStringmoredetails ForFeatureLayerthetypeisalways"feature". moredetailsFeatureLayer typeIdFieldStringmoredetailsThenameofthefieldholdingthetypeIDorsubtypesforthefeatures.moredetailsFeatureLayer typesFeatureType[]moredetailsAnarrayofsubtypesdefinedinthefeatureserviceexposedbyArcGISRESTAPI.moredetailsFeatureLayer urlStringmoredetailsTheabsoluteURLoftheRESTendpointofthelayer,non-spatialtableorservice.moredetailsFeatureLayer useViewTimeBooleanmoredetailsDeterminesifthelayerwillupdateitstemporaldatabasedontheview'stimeExtent.moredetailsFeatureLayer versionNumbermoredetailsTheversionofArcGISServerinwhichthelayerispublished.moredetailsFeatureLayer visibleBooleanmoredetailsIndicatesifthelayerisvisibleintheView.moredetailsLayer PropertyDetails apiKeyString Since:ArcGISAPIforJavaScript4.20 Anauthorizationstringusedtoaccessaresourceorservice. APIkeysaregeneratedandmanagedintheArcGISDeveloperdashboard. AnAPIkeyistiedexplicitlytoanArcGISaccount;itisalsousedtomonitorserviceusage. Settingafine-grainedAPIkeyonaspecificclassoverridestheglobalAPIkey. Example: //settheapikeytoaccessaprotectedservice constlayer=newFeatureLayer({ url:serviceUrl, apiKey:"YOUR_API_KEY" }); blendModeString Since:ArcGISAPIforJavaScript4.16 Blendmodesareusedtoblendlayerstogethertocreateaninterestingeffectinalayer,oreventoproducewhatseemslikeanewlayer. Unlikethemethodofusingtransparencywhichcanresultinawashed-outtoplayer,blendmodescancreateavarietyofveryvibrantandintriguing resultsbyblendingalayerwiththelayer(s)belowit. Whenblendinglayers,atoplayerisalayerthathasablendmodeapplied.Alllayersunderneaththetoplayerarebackgroundlayers. Thedefaultblendingmodeisnormalwherethetoplayerissimplydisplayedoverthebackgroundlayer.Whilethisdefaultbehaviorisperfectlyacceptable, theuseofblendmodesonlayersopenupaworldofendlesspossibilitiestogeneratecreativemaps. ThelayersinaGroupLayerareblendedtogetherinisolationfromtherestofthemap. Inthefollowingscreenshots,thevintageshadedrelief layerisdisplayedoverafireflyworldimagerylayer.Thecolorblendmode isappliedtothevintageshadedreliefandtheresultlookslikeanewlayer. KnownLimitations TheblendModein3DSceneViewsissupportedonBaseTileLayer,ImageryTileLayer, OpenStreetMapLayer,TileLayer,VectorTileLayer,WCSLayer, WebTileLayerandWMTSLayer. TheblendModein3DSceneViewwillbeignoredifthelayerisinsideaGroupLayer. TheblendModeisnotsupportedintheLegend. Seeprintforknownprintinglimitations. The followingfactorswillaffecttheblendresult: Orderofalllayers Layeropacity Opacityoffeaturesinlayers Visibilityoflayers Bydefault,theverybottomlayerinamapisdrawnonatransparentbackground.YoucanchangetheMapView'sbackgroundcolor. Blendmode Description normal Thetoplayerisdisplayedoverthebackgroundlayer.Thedataofthetoplayerblockthedataofbackgroundlayerwheretheyoverlap. average Takesthemathematicalaverageoftopandbackgroundlayers.Resultofaverageblendmodeisoftensimilartotheeffectofsettingthelayer'sopacityto50%. Lightenblendmodes: Thefollowingblendmodescreatelighterresultsthanalllayers.Inlightenblendmodes,pureblackcolorsinthetoplayerbecometransparentallowingthebackgroundlayertoshowthrough. Whiteinthetoplayerwillstayunchanged.Anycolorthatislighterthanpureblackisgoingtolightencolorsinthetoplayertovaryingdegreesallwaytopurewhite. Lightenblendmodescanbeusefulwhenlighteningdarkcolorsofthetoplayerorremovingblackcolorsfromtheresult. Theplus,lightenandscreenmodescanbeusedtobrightenlayersthathavefadedordarkcolorsonadarkbackground. Blendmode Description lighten Comparestopandbackgroundlayersandretainsthelightercolor.Colorsinthetoplayerbecometransparentiftheyaredarkerthantheoverlappingcolorsinthebackgroundlayerallowingthebackgroundlayertoshowthroughcompletely.Canbethoughtofastheoppositeofdarkenblendmode. lighter Colorsintopandbackgroundlayersaremultipliedbytheiralphas(layeropacityandlayer'sdataopacity.Thentheresultingcolorsareaddedtogether.Alloverlappingmidrangecolorsarelightenedinthetoplayer.Theopacityoflayerandlayer'sdatawillaffecttheblendresult. plus Colorsintopandbackgroundlayersareaddedtogether.Alloverlappingmidrangecolorsarelightenedinthetoplayer.Thismodeisalsoknownasaddorlinear-dodge. screen Multipliesinvertedcolorsintopandbackgroundlayerstheninvertsthecolorsagain.Theresultingcolorswillbelighterthantheoriginalcolorwithlesscontrast.Screencanproducemanydifferentlevelsofbrighteningdependingontheluminosityvaluesofthetoplayer.Canbethoughtofastheoppositeofthemultiplymode. color-dodge Dividescolorsinbackgroundlayerbytheinvertedtoplayer.Thislightensthebackgroundlayerdependingonthevalueofthetoplayer.Thebrighterthetoplayer,themoreitscoloraffectsthebackgroundlayer.Decreasesthecontrastbetweentopandbackgroundlayersresultinginsaturatedmid-tonesandblownhighlights. Darkenblendmodes: Thefollowingblendmodescreatedarkerresultsthanalllayers.Indarkenblendmodes,purewhiteinthetoplayerwillbecometransparentallowingthebackgroundlayertoshowthrough. Blackinthetoplayerwillstayunchanged.Anycolorthatisdarkerthanpurewhiteisgoingtodarkenatoplayertovaryingdegreesallthewaytopureblack. Themultiplyblendmodeisoftenusedtohighlightshadows,showcontrast,oraccentuateanaspectofamap.Forexample,youcanusemultiplyblendmodeonatopographicmap displayedoverhillshadewhenyouwanttohaveyourelevationshowthroughthetopographiclayer.Seetheintrotolayerblendingsample. Themultiplyanddarkenmodescanbeusedtohavedarklabelsofthebasemaptoshowthroughtoplayers.Seethedarkenblendingsample. Thecolor-burnmodeworkswellwithcolorfultopandbackgroundlayerssinceitincreasessaturationinmid-tones.Itincreasesthecontrastbytintingpixelsinoverlappingareasin topandbottomlayersmoretowardsthetoplayercolor.Usethisblendmode,whenyouwantaneffectwithmorecontrastthanmultiplyordarken. Thefollowingscreenshotsshowhowthemultiplyblendmodeusedforcreatingaphysicalmapoftheworldthatshowsbothboundariesandelevation. Blendmode Description darken Emphasizesthedarkestpartsofoverlappinglayers.Colorsinthetoplayerbecometransparentiftheyarelighterthantheoverlappingcolorsinthebackgroundlayer,allowingthebackgroundlayertoshowthroughcompletely. multiply Emphasizesthedarkestpartsofoverlappinglayersbymultiplyingcolorsofthetoplayerandthebackgroundlayer.Midrangecolorsfromtopandbackgroundlayersaremixedtogethermoreevenly. color-burn Intensifiesthedarkareasinalllayers.Itincreasesthecontrastbetweentopandbackgroundlayers,bytintingcolorsinoverlappingareatowardsthetopcolor.Todothisitinvertscolorsofthebackgroundlayer,dividestheresultbycolorsofthetoplayer,theninvertstheresults. Contrastblendmodes: Thefollowingblendmodescreatecontrastbybothlighteningthelighterareasanddarkeningthedarkerareasinthetoplayerbyusinglighteningordarkeningblendmodestocreatetheblend. Thecontrastblendmodeswilllightenthecolorslighterthan50%gray([128,128,128]),anddarkenthecolorsdarkerthan50%gray.50%graywillbetransparentinthetoplayer. Eachmodecancreateavarietyofresultsdependingonthecolorsoftopandbackgroundlayersbeingblendedtogether. Theoverlayblendmodemakesitscalculationsbasedonthebrightnessofthecolorsinthebackgroundlayerwhilealloftheothercontrastblendmodesmaketheircalculationsbasedonthebrightnessofthetoplayer. Someofthesemodesaredesignedtosimulatetheeffectofshiningalightthroughthetoplayer,effectivelyprojectinguponthelayersbeneathit. Contrastblendmodescanbeusedtoincreasethecontrastandsaturationtohavemorevibrantcolorsandgiveapunchtoyourlayers. Forexample,youcanduplicatealayerandsetoverlayblendmodeonthetoplayertoincreasethecontrastandtonesofyourlayer. Youcanalsoaddapolygonlayerwithawhitefillsymboloveradarkimagerylayerandapplysoft-lightblendmodetoincreasethebrightnessintheimagerylayer. ThefollowingscreenshotsshowaneffectoftheoverlayblendmodeonaGraphicsLayer.Theleftimageshowswhenthebuffergraphicslayerhasthenormalblendmode. Asyoucansee,thegraycolorforthebufferpolygonisblockingtheintersectingcensustracts.Therightimageshowswhentheoverlayblendmodeisappliedtothebuffergraphicslayer. Theoverlayblendmodedarkensorlightensthegraybufferpolygondependingonthecolorsofthebackgroundlayerwhilethecensustractslayerisshiningthrough. Seethisinaction. Normalblendmode Overlayblendmode Blendmode Description overlay Usesacombinationofmultiplyandscreenmodestodarkenandlightencolorsinthetoplayerwiththebackgroundlayeralwaysshiningthrough.Theresultisdarkercolorvaluesinthebackgroundlayerintensifythetoplayer,whilelightercolorsinthebackgroundlayerwashoutoverlappingareasinthetoplayer. soft-light Appliesahalfstrengthscreenmodetolighterareasandhalfstrengthmultiplymodetodarkenareasofthetoplayer.Youcanthinkofthesoft-lightasasofterversionoftheoverlaymode. hard-light Multipliesorscreensthecolors,dependingoncolorsofthetoplayer.Theeffectissimilartoshiningaharshspotlightonthetoplayer. vivid-light Usesacombinationofcolor-burnorcolor-dodgebyincreasingordecreasingthecontrast,dependingoncolorsinthetoplayer. Componentblendmodes: Thefollowingblendmodesuseprimarycolorcomponents,whicharehue,saturationandluminositytoblendtopandbackgroundlayers. Youcanaddafeaturelayerwithasimplerendereroveranylayerandsethue,saturation,colororluminosityblendmodeonthislayer.Withthistechnique,youcreateabrandnewlookingmap. Thefollowingscreenshotsshowwherethetopolayerisblendedwith worldhillshadelayerwithluminosityblendmode. Theresultisadrasticallydifferentlookingmapwhichpreservesthebrightnessofthetopolayerwhileadaptingthehueandsaturationofthehillshadelayer. Blendmode Description hue Createsaneffectwiththehueofthetoplayerandtheluminosityandsaturationofthebackgroundlayer. saturation Createsaneffectwiththesaturationofthetoplayerandthehueandluminosityofthebackgroundlayer.50%graywithnosaturationinthebackgroundlayerwillnotproduceanychange. luminosity Createseffectwiththeluminosityofthetoplayerandthehueandsaturationofthebackgroundlayer.Canbethoughtofastheoppositeofcolorblendmode. color Createsaneffectwiththehueandsaturationofthetoplayerandtheluminosityofthebackgroundlayer.Canbethoughtofastheoppositeofluminosityblendmode. Compositeblendmodes: Thefollowingblendmodescanbeusedtomaskthecontentsoftop,backgroundorbothlayers. Destinationmodesareusedtomaskthedataofthetoplayerwiththedataofthebackgroundlayer. Sourcemodesareusedtomaskthedataofthebackgroundlayerwiththedataofthetoplayer. Thedestination-inblendmodecanbeusedtoshowareasoffocussuchasearthquakes,animalmigration,orpoint-sourcepollutionbyrevealingtheunderlyingmap, providingabird’seyeviewofthephenomenon.CheckoutmultipleblendingandgroupLayerblending samplestoseecompositeblendmodesinaction. Thefollowingscreenshotsshowfeatureandimagerylayersontheleftsideontheirownintheordertheyaredrawnintheview.Theimagerylayerthatcontainslandcoverclassificationrasters. Thefeaturelayercontains2007countycropsdata.Therightimageshowstheresultoflayerblendingwheredestination-inblendModeissetontheimagerylayer.Asyoucansee,theeffectis verydifferentfromtheoriginallayers.Theblendedresultshowsareasofcultivatedcropsonly(wherebothimageryandfeaturelayersoverlap). Blendmode Description destination-over Destination/backgroundlayercoversthetoplayer.Thetoplayerisdrawnunderneaththedestinationlayer. You'llseethetoplayerpeekthroughwhereverthebackgroundlayeristransparentorhasnodata. destination-atop Destination/backgroundlayerisdrawnonlywhereitoverlapsthetoplayer.Thetoplayerisdrawnunderneaththebackgroundlayer.You'llseethetoplayerpeekthroughwhereverthebackgroundlayeristransparentorhasnodata. destination-in Destination/backgroundlayerisdrawnonlywhereitoverlapswiththetoplayer.Everythingelseismadetransparent. destination-out Destination/backgroundlayerisdrawnwhereitdoesn'toverlapthetoplayer.Everythingelseismadetransparent. source-atop Source/toplayerisdrawnonlywhereitoverlapsthebackgroundlayer.Youwillseethebackgroundlayerpeekthroughwherethesourcelayeristransparentorhasnodata. source-in Source/toplayerisdrawnonlywhereitoverlapswiththebackgroundlayer.Everythingelseismadetransparent. source-out Source/toplayerisdrawnwhereitdoesn'toverlapthebackgroundlayer.Everythingelseismadetransparent. xor Topandbackgroundlayersaremadetransparentwheretheyoverlap.Bothlayersaredrawnnormaleverywhereelse. Invertblendmodes: Thefollowingblendmodeseitherinvertorcanceloutcolorsdependingoncolorsofthebackgroundlayer. Theseblendmodeslookforvariationsbetweentopandbackgroundlayers. Forexample,youcanusedifferenceorexclusionblendmodesontwoimagerylayersofforestcoverstovisualizehowforestcoverschangedfromoneyeartoanother. Theinvertblendmodecanbeusedtoturnanylightbasemapintoadarkbasemaptoaccommodatethosewhoworkinlow-lightconditions.Thefollowingscreenshotsshow howsettingtheinvertblendmodesetonafeaturelayerwithasimplerendererturnstheworldterrainbasemap intoadarkthemedbasemapinnotime. Blendmode Description difference Subtracts thedarkeroftheoverlappingcolorsfromthelightercolor.Whentwopixelswiththesamevaluearesubtracted,theresultisblack. Blendingwithblackproducesnochange.Blendingwithwhiteinvertsthecolors.Thisblendingmodeisusefulforaligninglayerswithsimilarcontent. exclusion Similartothedifferenceblendmode,exceptthattheresultingimageislighteroverall.Overlappingareaswithlightercolorvaluesarelightened,whiledarkeroverlappingcolorvaluesbecometransparent. minus Subtractscolorsofthetoplayerfromcolorsofthebackgroundlayermakingtheblendresultdarker.Inthecaseofnegativevalues,blackisdisplayed. invert Invertsthebackgroundcolorswhereverthetopandbackgroundlayersoverlap.Theinvertblendmodeinvertsthelayersimilartoaphotographicnegative. reflect Thisblendmodecreateseffectsasifyouaddedshinyobjectsorareasoflightinthelayer.Blackpixelsinthebackgroundlayerareignoredasiftheyweretransparent. PossibleValues:"average"|"color-burn"|"color-dodge"|"color"|"darken"|"destination-atop"|"destination-in"|"destination-out"|"destination-over"|"difference"|"exclusion"|"hard-light"|"hue"|"invert"|"lighten"|"lighter"|"luminosity"|"minus"|"multiply"|"normal"|"overlay"|"plus"|"reflect"|"saturation"|"screen"|"soft-light"|"source-atop"|"source-in"|"source-out"|"vivid-light"|"xor" DefaultValue:normal Seealso: Layerblendingsamples capabilitiesObjectreadonly Describesthelayer'ssupportedcapabilities. Properties: attachment Object Describeswhatattachmentcapabilitiesareenabledonthelayer. Specification: supportsCacheHint Boolean Indicatesiftheattachmentoperationssupportacachehint.Thisisvalidonlyfor hostedfeatureservices. supportsContentType Boolean Indicatesiftheattachmentscanbequeriedbytheircontenttypes. supportsExifInfo Boolean IndicatesiftheattachmentqueriessupportexifInfo. supportsKeywords Boolean Indicatesiftheattachmentscanbequeriedbytheirkeywords. supportsName Boolean Indicatesiftheattachmentscanbequeriedbytheirnames. supportsSize Boolean Indicatesiftheattachmentscanbequeriedbytheirsizes. supportsResize Boolean Indicatesifresizedattachmentsaresupportedinthefeaturelayer. ThisisusefulforshowingthumbnailsinPopups. data Object Describescharacteristicsofthedatainthelayer. Specification: isVersioned Boolean Indicatesifthefeatureserviceisversioned. supportsAttachment Boolean Indicatesiftheattachmentisenabledonthelayer. supportsM Boolean Indicatesifthefeaturesinthelayersupportm-values. supportsZ Boolean Indicatesifthefeaturesinthelayersupportz-values. SeeelevationInfofordetailsregardingplacementandrenderingoffeatureswithz-valuesin3DSceneViews. editing Object DescribeseditingcapabilitiesthatcanbeperformedonthefeaturesinthelayerviaapplyEdits(). Specification: supportsDeleteByAnonymous Boolean Indicatesifanonymoususerscandeletefeaturescreatedbyothers. supportsDeleteByOthers Boolean Indicatesifloggedinuserscandeletefeaturescreatedbyothers. supportsGeometryUpdate Boolean Indicatesifthegeometryofthefeaturesinthelayercanbeedited. supportsGlobalId Boolean IndicatesiftheglobalIdvaluesprovidedbytheclientareusedinapplyEdits. supportsRollbackOnFailure Boolean IndicatesiftherollbackOnFailureEnabledparametercanbesettotrueorfalsewheneditingfeatures. supportsUpdateByAnonymous Boolean Indicatesifanonymoususerscanupdatefeaturescreatedbyothers. supportsUpdateByOthers Boolean Indicatesifloggedinuserscanupdatefeaturescreatedbyothers. supportsUploadWithItemId Boolean IndicatesifthelayersupportsuploadingattachmentsbyUploadId. supportsUpdateWithoutM Boolean Indicatesifm-valuesmustbeprovidedwhenupdatingfeatures. metadata Object Describesthemetadatacontainedonfeaturesinthelayer. Specification: supportsAdvancedFieldProperties Boolean Indicateswhethertoprovideauser-definedfielddescription. SeeDescribeattributefieldsforadditionalinformation. operations Object Describesoperationsthatcanbeperformedonfeaturesinthelayer. Specification: supportsAdd Boolean Indicatesifnewfeaturescanbeaddedtothelayer. supportsCalculate Boolean Indicatesifvaluesofoneormorefieldvaluesinthelayercanbeupdated. SeetheCalculateRESToperationdocumentformoreinformation. supportsDelete Boolean Indicatesiffeaturescanbedeletedfromthelayer. supportsEditing Boolean Indicatesiffeaturesinthelayercanbeedited. UsesupportsAdd,supportsUpdateandsupportsDeletetodeterminewhicheditingoperationsaresupported. supportsQuery Boolean Indicatesiffeaturesinthelayercanbequeried. supportsQueryAttachments Boolean Indicatesifthelayersupports RESTAPIqueryAttachmentsoperation. Iffalse,queryAttachments()methodcanonlyreturnattachmentsforonefeatureatatime. Iftrue,queryAttachments()canreturnattachmentsforarrayofobjectIds. supportsResizeAttachments Boolean Deprecatedsince4.24.Useattachment.supportsResizeinstead.Indicatesifresizedattachmentsaresupportedinthefeaturelayer. ThisisusefulforshowingthumbnailsinPopups. supportsQueryTopFeatures Boolean Indicatesifthelayersupports RESTAPIqueryTopFeaturesoperation. supportsUpdate Boolean Indicatesiffeaturesinthelayercanbeupdated. supportsValidateSql Boolean IndicatesifthelayersupportsaSQL-92expressionorwhereclause. query Object Describesquery operationsthatcanbeperformedonfeaturesinthelayer. Properties: maxRecordCount Number Themaximumnumberofrecordsthatwillbereturnedforagivenquery. supportsCacheHint Boolean Indicatesifthequeryoperationsupportsacachehint.Thisisvalidonlyfor hostedfeatureservices. supportsCentroid Boolean Indicatesifthegeometrycentroidassociatedwitheachpolygonfeaturecanbereturned.Thisoperationis onlysupportedinArcGISOnlinehostedfeatureservices. supportsDisjointSpatialRelationship Boolean Indicatesifthequeryoperationsupportsdisjointspatialrelationship.Thisisvalidonlyfor hostedfeatureservices. supportsDistance Boolean Indicatesifthelayer'squeryoperationsupportsabufferdistanceforinputgeometries. supportsDistinct Boolean IndicatesifthelayersupportsqueriesfordistinctvaluesbasedonfieldsspecifiedintheoutFields. supportsExtent Boolean Indicatesifthelayer'squeryresponseincludestheextentoffeatures. supportsGeometryProperties Boolean Indicatesifthelayer'squeryresponsecontainsgeometryattributes,includingshapeareaandlengthattributes. supportsHavingClause Boolean Indicatesifthelayersupportsthehavingclauseontheservice. supportsHistoricMoment Boolean Indicatesifthelayersupportshistoricmomentquery. supportsOrderBy Boolean Indicatesiffeaturesreturnedinthequeryresponsecanbeorderedbyoneormorefields. supportsPagination Boolean Indicatesifthequeryresponsesupportspagination. supportsPercentileStatistics Boolean IndicatesifthelayersupportspercentilestatisticType. supportsQuantization Boolean Indicatesifthequeryoperationsupportstheprojectionofgeometriesontoavirtualgrid. supportsQuantizationEditMode Boolean Indicatesifthequeryoperationsupportsquantizationdesignedtobeusedineditmode(highestresolutionatthegivenspatialreference). supportsQueryGeometry Boolean Indicatesifthequeryresponseincludesthequerygeometry. supportsResultType Boolean Indicatesifthenumberoffeaturesreturnedbythequeryoperationcanbecontrolled. supportsStandardizedQueriesOnly Boolean Indicatesifthelayersupportsusingstandardizedqueries. Learnmoreaboutstandardizedquerieshere. supportsStatistics Boolean Indicatesifthelayersupportsfield-basedstatisticalfunctions. supportsSqlExpression Boolean IndicatesifthelayersupportsSQLexpressions. supportsSpatialAggregationStatistics Boolean Indicatesifthelayersupportsspatialextent,centerorconvexhulltobereturnedforeachdistinctgroupwhen groupByFieldsForStatisticsisused.SupportedwithArcGISOnlinehostedfeaturesservicesonly. supportedSpatialStatisticAggregations Object ListofsupportedaggregatedgeometriesreturnedforeachdistinctgroupwhengroupByFieldsForStatisticsisused. Specification: centroid Boolean IndicatesifthelayercanreturncentroidforeachdistinctgroupforgroupByFieldsForStatistics. envelope Boolean IndicatesifthelayercanreturnextentforeachdistinctgroupforgroupByFieldsForStatistics. convexHull Boolean IndicatesifthelayercanreturnconvexhullforeachdistinctgroupforgroupByFieldsForStatistics. queryRelated Object Indicatesifthelayer'squeryoperationsupportsqueryingfeaturesorrecordsrelatedtofeaturesinthelayer. Specification: supportsCacheHint Boolean Indicatesiftherelationshipqueryoperationsupportsacachehint.Thisisvalidonlyfor hostedfeatureservices. supportsCount Boolean Indicatesifthelayer'squeryresponseincludesthenumberoffeaturesorrecordsrelatedtofeaturesinthelayer. supportsOrderBy Boolean Indicatesiftherelatedfeaturesorrecordsreturnedinthequeryresponsecanbeorderedbyoneormorefields. supportsPagination Boolean Indicatesifthequeryresponsesupportspaginationforrelatedfeaturesorrecords. queryTopFeatures Object Describestopfeaturesqueryoperationsthatcanbeperformedonfeaturesinthelayer. Specification: supportsCacheHint Boolean Indicatesifthetopqueryoperationsupportsacachehint.Thisisvalidonlyfor hostedfeatureservices. Example: //Oncethelayerloads,checkifthe //supportsAddoperationsisenabledonthelayer featureLayer.when(function(){ if(featureLayer.capabilities.operations.supportsAdd){ //ifnewfeaturescanbecreatedinthelayer //setuptheUIforediting setupEditing(); } }); copyrightString Copyrightinformationforthelayer. customParametersObject Since:ArcGISAPIforJavaScript4.18 AlistofcustomparametersappendedtotheURLofallresourcesfetchedbythelayer. It'sanobjectwithkey-valuepairswherevalueisastring. Example: //sendacustomparametertoyourspecialservice letlayer=newMapImageLayer({ url:serviceUrl, customParameters:{ "key":"my-special-key" } }); datesInUnknownTimezoneBooleanreadonly Since:ArcGISAPIforJavaScript4.21 Thispropertyissetbytheservicepublisherandindicatesthatdatesshouldbeconsideredwithoutthelocaltimezone. Thisappliestobothrequestsandresponses. KnownLimitations ThiscapabilityisonlyavailablewithservicespublishedwithArcGISEnterprise10.9orgreater. EditingisnotsupportedforFeatureLayersifdatesInUnknownTimezoneistrue.TheeditingEnabledpropertywillbesettofalse. ThispropertyisnothonoredbylabelsandArcade-basedpopupTemplates.Dateswillbedisplayedinthelocaltimezone. WhensettingtimeExtentinaquery,filterorlayer,datesmustbedefined intermsofUTCasillustratedinthecodebelow. Whenusinglayer.timeInfo.fullTimeExtentinconjunctionwithTimeSlider,thelocaltimezoneoffsetmustberemoved.Seethecodesnippetbelow. DefaultValue:false Seealso: ArcGISRESTAPI-Newin10.9 What'snewinArcGISServer10.9 Editmapservicesettings Examples: //Onlydownloaddatafortheyear2020. //ifthelayersupportsunknowntimezonethencreate //thedatesinUTC if(layer.datesInUnknownTimezone){ layer.timeExtent=newTimeExtent({ start:newDate(Date.UTC(2020,0,1)), end:newDate(Date.UTC(2021,0,1)) }); } else{ layer.timeExtent=newTimeExtent({ start:newDate(2020,0,1), end:newDate(2021,0,1) }); } //setupthetimesliderforaservicewithanunknowntimezone if(layer.datesInUnknownTimezone){ consttimeSlider=newTimeSlider({ view:view, container:"timeSliderDiv", timeVisible:true, }); view.ui.add(timeSlider,"bottom-left"); view.whenLayerView(layer).then((layerView)=>{ //getthelayer'sfullTimeExtentandremovethelocal //timezoneoffset consttimExtent=newTimeExtent({ start:removeLocalOffset(layer.timeInfo.fullTimeExtent.start), end:removeLocalOffset(layer.timeInfo.fullTimeExtent.end) }); timeSlider.fullTimeExtent=timExtent; timeSlider.stops={ interval:layer.timeInfo.interval; }; }); } //Removethelocaltimezoneoffsetfromdates functionremoveLocalOffset(localTime){ returnnewDate( localTime.getUTCFullYear(), localTime.getUTCMonth(), localTime.getUTCDate(), localTime.getUTCHours(), localTime.getUTCMinutes(), localTime.getUTCSeconds(), localTime.getUTCMilliseconds() ); } declaredClassStringreadonly inherited Since:ArcGISAPIforJavaScript4.7 Thenameoftheclass.Thedeclaredclassnameisformattedasesri.folder.className. definitionExpressionString TheSQLwhereclauseusedtofilterfeaturesontheclient.Onlythefeaturesthatsatisfythedefinition expressionaredisplayedintheView.Settingadefinitionexpressionisuseful whenthedatasetislargeandyoudon'twanttobringallfeaturestotheclientforanalysis. Definitionexpressionsmaybesetwhenalayerisconstructedpriortoitloadingintheviewor afterithasbeenaddedtothemap.Ifthedefinitionexpressionissetafterthelayerhasbeenaddedtothemap,theviewwill automaticallyrefreshitselftodisplaythefeaturesthatsatisfythenewdefinitionexpression. Examples: //SetdefinitionexpressioninconstructortoonlydisplaytreeswithscientificnameUlmuspumila constlayer=newFeatureLayer({ url:"https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0", definitionExpression:"Sci_Name='Ulmuspumila'" }); //Setthedefinitionexpressiondirectlyonlayerinstancetoonlydisplaytreestallerthan50ft layer.definitionExpression="HEIGHT>50"; displayFieldString Since:ArcGISAPIforJavaScript4.4 Thenameofthelayer'sprimarydisplayfield.Thevalueofthispropertymatchesthenameofoneofthefieldsofthelayer. dynamicDataSourceDynamicMapLayer|DynamicDataLayer Since:ArcGISAPIforJavaScript4.7 Anobjectthatallowsyoutocreateadynamiclayerwithdata eitherfrommapservicesublayersordatafromaregisteredworkspace. SeeDynamicMapLayer forcreatingdynamiclayersfrommapservicelayersforonthefly rendering,labeling,andfiltering(definitionexpressions).Tocreate dynamiclayersfromothersourcesinregisteredworkspacessuchastablesandtablejoins, seeDynamicDataLayer. IfyoualreadyhaveaSublayerinstance,you cancallthecreateFeatureLayer() methodontheSublayertoconstructthelayerforyou. Thisonlyappliestomapserviceswith dynamiclayersenabled. KnownLimitations FeatureLayerswithadynamicDataSourcecannotbepersistedtowebmaps,webscenes,andportalitems. Seealso: Sublayer.source Sublayer.createFeatureLayer() Example: constlayer=newFeatureLayer({ url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer", title:"UnitedStatesPopulation", popupTemplate:{ title:"{states.STATE_NAME}", content:"{expression/per_ancestry}%ofthe{states.POP2007}peoplein{states.STATE_NAME}have" +"Norwegianancestry.", expressionInfos:[{ name:"per_ancestry", expression:"Round(($feature['ancestry.norwegian']/$feature['states.POP2007'])*100,1)" }], fieldInfos:[{ fieldName:"states.POP2007", format:{ digitSeparator:true, places:0 } }] }, dynamicDataSource:{ type:"data-layer", dataSource:{ type:"join-table", leftTableSource:{ type:"map-layer", mapLayerId:3 }, rightTableSource:{ type:"data-layer", dataSource:{ type:"table", workspaceId:"CensusFileGDBWorkspaceID", dataSourceName:"ancestry" } }, leftTableKey:"STATE_NAME", rightTableKey:"State", joinType:"left-outer-join" } } }); editFieldsInfoEditFieldsInforeadonly Since:ArcGISAPIforJavaScript4.11 Theeditortrackingfields,whichrecordwhoaddsoreditsthedatathroughthefeatureservice andwheneditsaremade. editingEnabledBoolean Since:ArcGISAPIforJavaScript4.18 Determinesifthelayeriseditable. DefaultValue:true Seealso: applyEdits editingInfoEditingInforeadonly Since:ArcGISAPIforJavaScript4.12 Ifpresent,thisvaluespecifiesinformationaboutediting. effectEffectautocast Since:ArcGISAPIforJavaScript4.18 Effectprovidesvariousfilterfunctionsthatcanbeperformedonthelayertoachievedifferentvisualeffectssimilarto howimagefilterswork.Thispowerfulcapabilityallowsyoutoapplycssfilter-like functionstolayerstocreatecustomvisualeffectstoenhancethecartographicqualityofyourmaps.Thisisdonebyapplyingthedesired effecttothelayer'seffectpropertyasastringoranarrayofobjectstosetscaledependenteffects. Notes SetfeatureEffectpropertyifdifferenteffectsneedtobeappliedfeaturesthatmeetorfaila specifiedfilter. Ifallofthefollowingfourpropertiesareapplied,thentheywillbeappliedinthisorder:featureEffect,effect,opacityandblendMode. KnownLimitations Theeffectisnotsupportedin3DSceneViews. Theeffectcannotbeappliedtoalayerwithaheatmaprenderer. TheeffectisnotsupportedinlayerswithfeatureReductionoftypeclusterenabled. Seeprintforknownprintinglimitations. DefaultValue:null Seealso: featureEffect Moreinformationonhowtoseteffect Layerandlayervieweffectsamples Examples: //thefollowingeffectwillbeappliedtothelayeratallscales //brightnesswillbeappliedfirst,thenhue-rotatefollowedbycontrast //changingorderoftheeffectswillchangethefinalresult layer.effect="brightness(5)hue-rotate(270deg)contrast(200%)"; //setascaledependentbloomeffectonthelayer layer.effect=[ { scale:36978595, value:"drop-shadow(3px,3px,4px)" }, { scale:18489297, value:"drop-shadow(2px,2px,3px)" }, { scale:4622324, value:"drop-shadow(1px,1px,2px)" } ]; elevationInfoObject Specifieshowfeaturesareplacedontheverticalaxis(z).Thispropertymayonlybeused inaSceneView.SeetheElevationInfosample foranexampleofhowthispropertymaybeused. Properties: mode String Defineshowthefeature isplacedwithrespecttotheterrainsurfaceor3Dobjectsinthescene.Ifthegeometryconsistsofmultiplepoints (e.g.linesorpolygons),theelevationisevaluatedseparatelyforeachpoint.Seethetablebelowforalistofpossiblevalues. Mode Description on-the-ground FeaturesarealignedtotheGround.IfthescenecontainsanIntegratedMeshLayer,thenfeaturesarealignedtotheIntegratedMeshLayer.Iffeatureshavez-values,thenthez-valuesareignoredinthismode.Featureswith2DsymbolsaredrapedontheGroundorIntegratedMeshLayer.Thisisthedefaultmodeforlayerswithoutz-valuescontainingPolyline,PolygonfeaturesorPointfeaturesrenderedwithObjectSymbol3DLayer. absolute-height Featuresareplacedatanabsoluteelevation(z-value)abovesealevel.Thisz-valueisdeterminedbythegeometry'sz-value(ifpresent).IffeatureExpressionInfoisdefined,theresultoftheexpressionisusedinsteadofthegeometry’sz-value.Thismodedoesn'ttaketheelevationoftheGroundoranyotherlayersintoaccount.ThisisthedefaultvalueoffeatureswithanygeometrytypewherehasZistrue. relative-to-ground FeaturesareplacedatanelevationrelativetotheGroundorIntegratedMeshLayer.Thefeature'selevationisdeterminedbysumminguptheelevationoftheGroundorIntegratedMeshLayerandthegeometry'sz-value(ifpresent).IffeatureExpressionInfoisdefined,theresultoftheexpressionisusedinsteadofthegeometry’sz-value.Ifthegeometriesdon'thavez-values,relative-to-groundisthedefaultvalueforPointgeometriesrenderedwithIconSymbol3DLayers. relative-to-scene Featuresarealignedtoextrudedpolygons,3DObjectSceneLayersorBuildingSceneLayers,dependingonwhichonehashigherelevation.Ifthefeatureisnotdirectlyaboveabuildingoranyotherfeature,itisalignedtotheelevationoftheGroundortheIntegratedMeshLayer.Ifpresent,thegeometry'sz-valueisaddedtotheelevation.IffeatureExpressionInfoisdefined,theresultoftheexpressionisusedinsteadofthegeometry’sz-value. PossibleValues:"on-the-ground"|"relative-to-ground"|"absolute-height"|"relative-to-scene" offset Number optional Anelevationoffset,whichisaddedtotheverticalpositionofthefeature.Ifunitisnotdefined,theoffset isinmeters. Whenmode="on-the-ground",thispropertyhasnoeffect. featureExpressionInfo Object optional Defineshowtooverrideafeature'sZ-valuebasedonitsattributes. Specification: expression String optional AnArcadeexpression followingthespecification definedbytheArcadeFeatureZProfile.Expressions mayreferencefieldvaluesusingthe$featureglobalvariableandmustreturnanumberrepresentingthez-value ofthefeature.Whenmode="on-the-ground",thispropertyhasnoeffect.Forlineandpolygongeometries theresultoftheexpressionisthesameforallverticesofafeature. unit String optional TheunitforfeatureExpressionInfoandoffsetvalues. PossibleValues:"feet"|"meters"|"kilometers"|"miles"|"us-feet"|"yards" Seealso: ArcadeFeatureZProfile featureEffectFeatureEffectautocast Since:ArcGISAPIforJavaScript4.22 ThefeatureEffectcanbeusedtodrawattentionfeaturesofinterest. Itallowsfortheselectionoffeaturesviaa filter,andan includedEffectand excludedEffect areappliedtothosefeaturesthatrespectivelypassorfailthefilterrequirements. Notes Settheeffectpropertyiftheeffectneedstobeappliedtotheentirelayer. IfthefeatureEffectissetonthelayer,itwillbeinheritedbylayerView.featureEffectunlessthedeveloperoverridesitonthelayerview.ThelayerView.featureEffect willtakeprecedenceoverlayer.featureEffectifbothpropertiesareset. Ifallofthefollowingfourpropertiesareapplied,thentheywillbeappliedinthisorder:featureEffect,effect,opacityandblendMode. KnownLimitations FeatureEffectisnotsupportedinthefollowingscenarios: In3DSceneViews InalayerrenderedwithaHeatmapRenderer WhenFeatureReductionClusterisenabled Seeprintforknownprintinglimitations. Seealso: Sample-Applyeffectstofeatures Sample-Applydrop-shadoweffecttoalayerView effect Examples: //grayoutfeaturesthatfalloutsideofthe3milebufferofthemouse'slocation //bysettingfeatureeffectonexcludedfeatures layer.featureEffect=newFeatureEffect({ filter:newFeatureFilter({ geometry:filterGeometry, spatialRelationship:"intersects", distance:3, units:"miles" }), excludedEffect:"grayscale(100%)opacity(30%)" }); //Applyadrop-shadowfeatureeffecttothefeaturesthatintersecttheboroughboundaries, //whileapplyingblurandbrightnesseffectstothefeaturesthatareexcludedfromfiltercriteria. //Theresultingmapwillmakeiteasiertospotiftheresidentsaremorelikelytoexperiencedeprivation //iftheyliveonaboroughboundary. constfeatureFilter=newFeatureFilter({ where:"BoroughEdge='true'" }); layer.featureEffect=newFeatureEffect({ filter:featureFilter, includedEffect:"drop-shadow(3px,3px,3px,black)", excludedEffect:"blur(1px)brightness(65%)" }); featureReductionFeatureReductionBinning|FeatureReductionCluster|FeatureReductionSelectionautocast Since:ArcGISAPIforJavaScript4.4 Configuresthemethodforreducingthenumberofpointfeaturesintheview. Bydefaultthispropertyisnull,whichindicatesthelayerviewshoulddraweveryfeature. Therearethreetypesoffeaturereduction:selection,cluster,andbinning. SelectiononlyappliestopointsinaSceneView andinvolvesthinningoverlappingfeaturessonofeatures intersectonscreen.Thishasbeenavailablesinceversion4.4. ClustergroupspointsinaMapView intoclustersdefinedinscreenspace.Eachclusterisapointwhosesizeisproportionaltothenumberoffeatureswithinthecluster.Thishasbeenavailablesinceversion4.14. BinningspatiallygroupspointsinaMapView intobinsclearlydefiningtheareaaggregatingfeaturesinmapspace.Thishasbeenavailablesinceversion4.24. Seealso: Sample-Pointclustering Sample-Pointclusteringwithvisualvariables Sample-Filterclusteredpoints Sample-Pointstylesforcities Examples: //clusterspointsbasedontheirspatialproximitytootherpoints layer.featureReduction={ type:"cluster", clusterRadius:100 }; //thinsfeaturesintheview layer.featureReduction={ type:"selection" }; //Aggregatesfeaturestobins layer.featureReduction={ type:"binning", renderer:{ type:"simple",//autocastsasnewSimpleRenderer() symbol:{ type:"simple-fill",//autocastsasnewSimpleFillSymbol() outline:{//autocastsasnewSimpleLineSymbol() width:0.5, color:"white" } }, visualVariables:[{ type:"color", field:"aggregateCount", stops:[ {value:1,color:"white"}, {value:1000,color:"blue"} ] }] }, popupTemplate:{ content:"Thisbincontains{aggregateCount}features.", fieldInfos:[{ fieldName:"aggregateCount", format:{ digitSeparator:true, places:0 } }] } }; fieldsField[]autocast Autocastsfrom Object[] Anarrayoffieldsinthelayer.Eachfieldrepresentsanattribute thatmaycontainavalueforeachfeatureinthelayer.Forexample, afieldnamedPOP_2015,storesinformationabouttotalpopulationasa numericvalueforeachfeature;thisvaluerepresentsthetotalnumber ofpeoplelivingwithinthegeographicboundsofthefeature. WhencreatingaFeatureLayerfromclient-sidefeatures,thisproperty shouldbesetintheconstructoralongwiththesourceproperty.TheobjectId fieldalsomustbeseteitherinthisarrayorintheobjectIdFieldproperty. Seealso: source objectIdField Addanarrayofclient-sidefeatures Example: //defineeachfield'sschema constfields=[ newField({ name:"ObjectID", alias:"ObjectID", type:"oid" }),newField({ name:"description", alias:"Description", type:"string" }),newField({ name:"title", alias:"Title", type:"string" }) ]; //Seethesamplesnippetforthesourceandrendererproperties constlayer=newFeatureLayer({ //geometryTypeandspatialReferenceareinferred //fromtheinputsourcefeatures source:features, //ObjectIDfieldisinferredfromthefieldsarray fields:fields, renderer:renderer }); fieldsIndexFieldsIndexreadonly Since:ArcGISAPIforJavaScript4.12 Aconvenientpropertythatcanbeusedtomakecase-insensitivelookupsforafieldbyname. Itcanalsoprovidealistofthedatefieldsinalayer. Example: //lookupafieldbyname.nameiscase-insensitive constfield=layer.fieldsIndex.get("SoMeFiEld"); if(field){ console.log(field.name);//SomeField } floorInfoLayerFloorInfoautocast Since:ArcGISAPIforJavaScript4.19 Whenafeaturelayerisconfiguredasfloor-aware,ithasafloorInfopropertydefined. Afloor-awarelayerisalayerthatcontainsindoorGISdatarepresentingfeaturesthat canbelocatedonaspecificfloorofabuilding. formTemplateFormTemplateautocast Since:ArcGISAPIforJavaScript4.16 Thetemplateusedinanassociatedlayer'sFeatureForm.Allofthepropertiesandfieldconfigurationssetonthelayer'sFeatureFormarehandledviatheFormTemplate. Seealso: Sample-UpdateFeatureAttributes Example: //CreatetheFieldElementstopassintothetemplate constfieldElement1=newFieldElement({ fieldName:"firstname", label:"Firstname", description:"Firstnameofemergencycontact" }); constfieldElement2=newFieldElement({ fieldName:"lastname", label:"Lastname", description:"Lastnameofemergencycontact" }); //Createtheform'stemplate constformTemplate=newFormTemplate({ title:"Emergencyinformation", description:"Incaseofemergency,updateanyadditionalinformationneeded", elements:[fieldElement1,fieldElement2]//passinarrayoffieldelementsfromabove }); //Passthetemplatetothelayer featureLayer.formTemplate=formTemplate; //PassthelayertotheFeatureForm constform=newFeatureForm({ container:"form",//htmldivreferencingtheform layer:featureLayer }); fullExtentExtentautocast inherited Thefullextentofthelayer.Bydefault,thisisworldwide.Thispropertymaybeused tosettheextentoftheviewtomatchalayer'sextentsothatitsfeatures appeartofilltheview.Seethesamplesnippetbelow. Example: //Oncethelayerloads,settheview'sextenttothelayer'sfullextent layer.when(function(){ view.extent=layer.fullExtent; }); gdbVersionString Theversionofthegeodatabaseofthefeatureservicedata.Read theOverviewofversioningtopicformoredetails aboutthiscapability. geometryFieldsInfoGeometryFieldsInforeadonly Since:ArcGISAPIforJavaScript4.19 Providesinformationonthesystemmaintainedareaandlengthfieldsalongwiththeirrespectiveunits. Seealso: ArcGISRESTAPIdocumentation geometryTypeString Thegeometrytypeoffeaturesinthelayer.Allfeaturesmustbeofthesametype. Thispropertyisread-onlywhenthelayeriscreatedfromaurl. WhencreatingaFeatureLayerfromclient-sidefeatures,thispropertyis inferredbythegeometryTypeofthefeaturesprovidedinthelayer'ssource property.Ifthelayer'ssourceisanemptyarrayatthetimeofinitialization, thispropertymustbeset. PossibleValues:"point"|"multipoint"|"polyline"|"polygon"|"multipatch"|"mesh" Seealso: Addanarrayofclient-sidefeatures hasMBoolean Indicateswhethertheclient-sidefeaturesinthelayerhaveM(measurement)values. UsethesupportsMpropertyintheFeatureLayer'scapabilities.data objecttoverifyifMvaluesaresupportedonfeatureservicefeatures. DefaultValue:undefined hasZBoolean Indicateswhethertheclient-sidefeaturesinthelayerhaveZ(elevation)values. RefertoelevationInfofordetailsregardingplacementandrendering offeatureswithz-valuesin3DSceneViews. UsethesupportsZpropertyintheFeatureLayer'scapabilities.data objecttoverifyifZvaluesaresupportedonfeatureservicefeatures. DefaultValue:undefined historicMomentDateautocast Since:ArcGISAPIforJavaScript4.7 Thehistoricmomenttoquery.IfhistoricMomentisnotspecified,thequery willapplytothecurrentfeatures. idString inherited TheuniqueIDassignedtothelayer.Ifnotsetbythedeveloper,itisautomatically generatedwhenthelayerisloaded. isTableBooleanreadonly Since:ArcGISAPIforJavaScript4.11 Returnstrueifthelayerisloadedfromanon-spatialtableinaservice.Non-spatialtablesdonothave aspatialcolumnthatrepresentgeographicfeatures. DefaultValue:false Seealso: Map.tables WebMap.tables Map.allTables WebMap.allTables labelingInfoLabelClass[]autocast Autocastsfrom Object[] Thelabeldefinitionforthislayer,specifiedasanarrayof LabelClass.Usethispropertytospecify labelingpropertiesforthelayersuchaslabelexpression,placement,andsize. MultipleLabelclasseswithdifferentwhereclausescanbeusedtodefineseveral labelswithvaryingstylesonthesamefeature.Likewise,multiplelabelclasses maybeusedtolabeldifferenttypesoffeatures(forexamplebluelabels forlakesandgreenlabelsforparks). SeetheLabelingguidepageformoreinformationandknownlimitations. KnownLimitations 3DSceneViewsonlysupportdisplayingoneLabelClassperfeature. Seealso: Sample:Addmultiplelabelclassestoalayer Sample:Multi-linelabels Sample:Flatvs.volumetric3Dsymbollayers Example: conststatesLabelClass=newLabelClass({ labelExpressionInfo:{expression:"$feature.NAME"}, symbol:{ type:"text",//autocastsasnewTextSymbol() color:"black", haloSize:1, haloColor:"white" } }); featureLayer.labelingInfo=[statesLabelClass]; labelsVisibleBoolean Indicateswhethertodisplaylabelsforthislayer.Iftrue,labelswill appearasdefinedinthelabelingInfoproperty. KnownLimitations 3DSceneViewsonlysupportdisplayingoneLabelClassperfeature. DefaultValue:true layerIdNumber ThelayerID,orlayerindex,ofaFeatureServicelayer.Thisisparticularlyusefulwhen loadingasingleFeatureLayerwiththeportalItempropertyfromaservicecontaining multiplelayers.Youcanspecifythisvalueinoneoftwoscenarios: WhenloadingthelayerviatheportalItemproperty. WhenpointingthelayerurldirectlytotheFeatureService. IfalayerIdisnotspecifiedineitheroftheabovescenarios,thenthefirstlayer intheservice(layerId=0)isselected. Examples: //loadsthethirdlayerinthegivenPortalItem constlayer=newFeatureLayer({ portalItem:{ id:"8d26f04f31f642b6828b7023b84c2188" }, layerId:2 }); //Ifnotspecified,thefirstlayer(layerId:0)willbereturned constlayer=newFeatureLayer({ portalItem:{ id:"8d26f04f31f642b6828b7023b84c2188" } }); //CanalsobeusedifURLpointstoserviceandnotlayer constlayer=newFeatureLayer({ //Noticethattheurldoesn'tendwith/2 url:"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer", layerId:2 }); //Thiscodereturnsthesamelayerastheprevioussnippet constlayer=newFeatureLayer({ //ThelayeridisspecifiedintheURL url:"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer/2", }); legendEnabledBoolean Indicateswhetherthelayerwillbeincludedinthelegend. DefaultValue:true listModeString inherited IndicateshowthelayershoulddisplayintheLayerListwidget. Thepossiblevaluesarelistedbelow. Value Description show Thelayerisvisibleinthetableofcontents. hide Thelayerishiddeninthetableofcontents. hide-children IfthelayerisaGroupLayer,BuildingSceneLayer,KMLLayer,MapImageLayer,TileLayerorWMSLayer,hidethechildrenlayersfromthetableofcontents. PossibleValues:"show"|"hide"|"hide-children" DefaultValue:show loadedBooleanreadonly inherited Indicateswhetherthelayer'sresourceshaveloaded.Whentrue, allthepropertiesoftheobjectcanbeaccessed. DefaultValue:false loadErrorErrorreadonly inherited TheErrorobjectreturnedifanerroroccurredwhileloading. DefaultValue:null loadStatusStringreadonly inherited Representsthestatusofaloadoperation. Value Description not-loaded Theobject'sresourceshavenotloaded. loading Theobject'sresourcesarecurrentlyloading. loaded Theobject'sresourceshaveloadedwithouterrors. failed Theobject'sresourcesfailedtoload.SeeloadErrorformoredetails. PossibleValues:"not-loaded"|"loading"|"failed"|"loaded" DefaultValue:not-loaded loadWarningsObject[]readonly inherited Alistofwarningswhichoccurredwhileloading. maxScaleNumber Themaximumscale(mostzoomedin)atwhichthelayerisvisibleintheview. Ifthemapiszoomedinbeyondthisscale,thelayerwillnotbevisible. Avalueof0meansthelayerdoesnothaveamaximumscale. ThemaxScalevalueshouldalwaysbesmallerthantheminScalevalue, andgreaterthanorequaltotheservicespecification. DefaultValue:0 Examples: //Thelayerwillnotbevisiblewhentheviewiszoomedinbeyondascaleof1:1,000 layer.maxScale=1000; //Thelayer'svisibilityisnotrestrictedtoamaximumscale. layer.maxScale=0; minScaleNumber Theminimumscale(mostzoomedout)atwhichthelayerisvisibleintheview. Ifthemapiszoomedoutbeyondthisscale,thelayerwillnotbevisible. Avalueof0meansthelayerdoesnothaveaminimumscale. TheminScalevalueshouldalwaysbelargerthanthemaxScalevalue, andlesserthanorequaltotheservicespecification. DefaultValue:0 Examples: //Thelayerwillnotbevisiblewhentheviewiszoomedoutbeyondascaleof1:3,000,000 layer.minScale=3000000; //Thelayer'svisibilityisnotrestrictedtoaminimumscale. layer.minScale=0; objectIdFieldString Thenameofanoidfieldcontaining auniquevalueoridentifierforeachfeatureinthelayer. ThispropertyisrequiredwhenconstructingaFeatureLayerfromacollection ofclient-sidefeatures.Ifnotspecified,itwillbeinferred fromthefieldsarray. Seealso: fields Addanarrayofclient-sidefeatures Example: //Seethesamplesnippetforthesourceandfieldsproperties constlayer=newFeatureLayer({ source:features, fields:fields, objectIdField:"ObjectID",//fieldnameoftheObjectIDs geometryType:"point", renderer: }); opacityNumber inherited Theopacityofthelayer.Thisvaluecanrangebetween1and0,where0is100percent transparentand1iscompletelyopaque. DefaultValue:1 Example: //Makesthelayer50%transparent layer.opacity=0.5; orderByObject[] Since:ArcGISAPIforJavaScript4.21 Determinestheorderinwhichfeaturesaredrawnintheview.You cansortfeaturesbyafieldvalueorthevaluereturnedfroman Arcadeexpressioninascendingordescendingorder. Whennull(default),featuresaredrawnintheordertheyarereturnedfrom theserviceorclient. KnownLimitations ThispropertyonlycontrolsfeaturedrawingorderinMapView.Configuring featuredrawingorderinSceneViewisnotsupported. Thispropertydoesnotcontrolthedrawingorderofclusters.Itonlyappliestoindividualfeatures. FeaturedrawingorderconfigurationsdefinedwithArcadeexpressionscannotbesavedtowebmaps. Currently,youcanonlysortfeaturesbyonefieldorexpression. Properties: field String optional Thenumberordatefieldwhosevalueswillbeusedtosortfeatures. valueExpression String optional AnArcadeexpression followingthespecificationdefinedbytheArcadeFeatureZProfile. Expressionsmayreferencefieldvaluesusingthe$featureglobalvariableandmustreturnanumberor adaterepresentingthez-valueusedtosortfeatures. order String optional DefaultValue:ascending Thesortorder.Ifascending,thenfeatures withsmallerdatavalues(theyusuallyhavesmallersymbolsinsizevisualizations)willbedrawnontopoffeatures withlargerdatavalues.Ifdescending,thenfeatures withlargerdatavalues(usuallylargersymbolsinsizevisualizations)willbedrawnontopoffeatures withsmallerdatavalues.Ifdatevaluesareused,thenascendingmeansfeatureswitholdervalueswill bedrawnontopoffeatureswithmorerecentdates.Adescendingorderfordatesindicatesfeatureswithmore recentvalueswillbedrawnontopoffeatureswitholdervalues. PossibleValues:"ascending"|"descending" DefaultValue:null Seealso: ArcadeFeatureZProfile Examples: //Featureswithsmallerpopulationvalueswill //berenderedontopoflargerfeatures. layer.orderBy=[{ field:"POPULATION" }]; //Featureswithlargerpopulationvalueswill //berenderedontopofsmallerfeatures. layer.orderBy=[{ field:"POPULATION", order:"descending" }]; //Ordersfeaturesbydateindescendingorder. //Themostrecentfeatureswillberendered //ontopofolderfeatures. layer.orderBy=[{ field:"Alarm_Date", order:"descending" }]; //Ordersfeaturesbystormwarningdurationindescendingorder. //Warningswithlongerdurations //berenderedontopofwarningswithshorterdurations. layer.orderBy=[{ valueExpression:"DateDiff($feature.Watch_End,$feature.Watch_Start,'hours')", order:"descending" }]; //Ordersfeaturesbydatavaluesusedinasizevisualvariable constsizeVariable=layer.renderer.visualVariables.find(vv=>vv.type==="size"); const{field,valueExpression}=sizeVariable; layer.orderBy=[{ field, valueExpression, order:"ascending" }]; outFieldsString[] Anarrayoffieldnamesfromtheservicetoincludewitheachfeature. Tofetchthevaluesfromallfieldsinthelayer,use["*"].Fieldsspecifiedin outFieldswillberequestedalongsidewithrequiredfieldsforrendering, labelingandsettingtheelevationinfoforthelayer. TherequiredfieldsandoutFieldsareusedtopopulate FeatureLayerView.availableFields. Setthispropertytoincludethefieldsthatwillbeusedforclient-side queries ifthefieldsarenotpartofrequiredfieldsusedforrendering. DefaultValue:null Seealso: FeatureLayerView.availableFields fieldUtils Examples: //Includesallfieldsfromtheserviceinthelayer fl.outFields=["*"]; //Getthespecifiedfieldsfromtheserviceinthelayer //ThesefieldswillbeaddedtoFeatureLayerView.availableFields //alongwithrenderingandlabelingfields.Usethesefields //forclient-sidefilteringandquerying. fl.outFields=["NAME","POP_2010","FIPS","AREA"]; //settheoutFieldsforthelayercomingfromwebmap webmap.when(function(){ layer=webmap.layers.getItemAt(1); layer.outFields=["*"]; }); popupEnabledBoolean Indicateswhethertodisplaypopupswhenfeaturesinthelayerareclicked.ThelayerneedstohaveapopupTemplatetodefinewhat informationshouldbedisplayedinthepopup.Alternatively,adefaultpopuptemplatemaybeautomaticallyusedif Popup.defaultPopupTemplateEnabledissettotrue. DefaultValue:true Seealso: createPopupTemplate View popupTemplatePopupTemplateautocast Thepopuptemplateforthelayer.Whensetonthelayer,thepopupTemplate allowsuserstoaccessattributesanddisplaytheirvaluesinthe view'spopupwhenafeatureisselected usingtextand/orcharts.SeethePopupTemplatesample foranexampleofhowPopupTemplateinteractswitha FeatureLayer. AdefaultpopuptemplateisautomaticallyusedifnopopupTemplatehasbeendefinedwhen Popup.defaultPopupTemplateEnabled issettotrue. Seealso: createPopupTemplate View portalItemPortalItem Theportalitemfromwhichthelayerisloaded.Iftheportalitemreferences aFeatureServiceorSceneService,thenyoucanspecifyasinglelayer toloadwiththelayerIdproperty. Beginningwithversion4.17,itispossibletoloadtablesfromfeatureserviceitemshostedinArcGISOnlineandArcGISEnterprise. Thisonlyappliestofeaturelayers,andwillsuccessfullyload ifFeatureLayer.isTablereturnstrue. Examples: //WhilethisexampleusesFeatureLayer,thissamepatterncanbe //usedforotherlayersthatmaybeloadedfromportalItemids. constlyr=newFeatureLayer({ portalItem:{//autocastsasnewPortalItem() id:"caa9bd9da1f4487cb4989824053bb847" }//thefirstlayerintheserviceisreturned }); //Sethostnamewhenusinganon-premiseportal(defaultisArcGISOnline) //esriConfig.portalUrl="http://myHostName.esri.com/arcgis"; //WhilethisexampleusesFeatureLayer,thissamepatterncanbe //usedforSceneLayers. constlyr=newFeatureLayer({ portalItem:{//autocastsasnewPortalItem() id:"8d26f04f31f642b6828b7023b84c2188" }, //loadsthethirditeminthegivenfeatureservice layerId:2 }); //ThissnippetloadsatablehostedinArcGISOnline. consttable=newFeatureLayer({ portalItem:{//autocastsasesri/portal/PortalItem id:"123f4410054b43d7a0bacc1533ceb8dc" } }); //Beforeaddingthetabletothemap,itmustfirstbeloadedandconfirmitistherighttype. table.load().then(function(){ if(table.isTable){ map.tables.add(table); } }); refreshIntervalNumber Since:ArcGISAPIforJavaScript4.6 Refreshintervalofthelayerinminutes.Valueof0indicatesnorefresh. Ateachrefreshinterval,thedataisonlyupdatedifthelastEditDateinthelayer'smetadataisdifferentfromthelastEditDatefield. IfthelastEditDatemetadatainfoisnotavailable,theFeatureLayerrefreshesunconditionally. DefaultValue:0 Seealso: refresh() refreshevent Example: //thelayerwillberefreshedevery6seconds. layer.refreshInterval=0.1; relationshipsRelationship[]readonly Since:ArcGISAPIforJavaScript4.9 Arrayofrelationshipssetupforthelayer.Eachobjectinthearraydescribesthelayer's relationshipwithanotherlayerortable. Seealso: FeatureLayer.queryRelatedFeatures Example: //printoutlayer'srelationshiplengthandeachrelationshipinfotoconsole featureLayer.when(function(){ console.log("layerrelationships",featureLayer.relationships.length); featureLayer.relationships.forEach(function(relationship){ console.log("relationshipid:",relationship.id) console.log("relationshipcardinality:",relationship.cardinality) console.log("relationshipkeyfield:",relationship.keyField) console.log("relationshipname:",relationship.name) console.log("relationshiprelatedTableId:",relationship.relatedTableId) }); }); rendererRendererautocast Therendererassignedtothelayer.Therendererdefineshowto visualizeeachfeatureinthelayer.Dependingontherenderertype, featuresmaybevisualizedwiththesamesymbol,orwithvaryingsymbols basedonthevaluesofprovidedattributefieldsorfunctions. However,whencreatingaFeatureLayerfromclient-sidefeatures,thispropertymust bespecifiedinthelayer'sconstructoralongwiththe source, fields,objectIdFieldproperties. Seealso: Creatingvisualizationsmanually Manuallydefinedrenderers Example: //allfeaturesinthelayerwillbevisualizedwith //a6ptblackmarkersymbolandathin,whiteoutline layer.renderer={ type:"simple",//autocastsasnewSimpleRenderer() symbol:{ type:"simple-marker",//autocastsasnewSimpleMarkerSymbol() size:6, color:"black", outline:{//autocastsasnewSimpleLineSymbol() width:0.5, color:"white" } } }; returnMBoolean Whentrue,indicatesthatMvalueswillbereturned.When false,indicatesthatMvalueswillneverbereturned.Thelayerview determineswhethertoincludeMvaluesinfeaturequerieswhenthe propertyvalueisundefined. DefaultValue:undefined returnZBoolean Whentrue,indicatesthatz-valueswillalwaysbereturned.When false,indicatesthatz-valueswillneverbereturned.Thelayerview determineswhethertoincludez-valuesinfeaturequerieswhenthe propertyvalueisundefined. DefaultValue:undefined screenSizePerspectiveEnabledBoolean Since:ArcGISAPIforJavaScript4.4 Applyperspectivescalingtoscreen-sizepointsymbolsinaSceneView. Whentrue,screensizedobjectssuchasicons, labelsorcalloutsintegrate betterinthe3Dscenebyapplyingacertainperspectiveprojectiontothe sizingoffeatures.ThisonlyapplieswhenusingaSceneView. layer.screenSizePerspectiveEnabled=true layer.screenSizePerspectiveEnabled=false KnownLimitations Screensizeperspectiveiscurrentlynotoptimizedforsituationswherethecameraisveryneartheground,orforscenes withpointfeatureslocatedfarfromthegroundsurface.Inthesecasesitmaybebettertoturnoffscreensizeperspective. Asscreensizeperspectivechangesthesizebasedondistancetothecamera,itshouldbesettofalsewhenusingsizevisualvariables. DefaultValue:true Seealso: Sample:Pointstylesforcities serviceDefinitionExpressionStringreadonly Since:ArcGISAPIforJavaScript4.16 Theservicedefinitionexpressionlimitsthefeaturesavailablefordisplayandquery.Youcandefineadditionalfiltersonthelayerinadditiontotheservicedefinitionexpression bysettinglayer'sdefinitionExpression.Forexample,iftheservicedefinitionexpressionissettodisplaydatawhere"STATE_NAME='California'" youcouldusedefinitionExpressiontoonlydisplayasubsetofthefeaturesinCalifornia,forexampleusing"COUNTY='SanDiego'". Seealso: Sethostedfeaturelayerviewdefinition sourceCollectionautocast Autocastsfrom Object[] AcollectionofGraphicobjectsusedtocreateaFeatureLayer. ThegeometryofeachfeatureallmusthaveamatchinggeometryType. ThispropertymustbesetwhencreatingaFeatureLayerfromclient-sidefeatures. WhencreatingaFeatureLayerfromclient-sidefeatures,theobjectIdfieldmustbeset eitherinthefieldsarrayorviaobjectIdField. ThespatialReferenceandgeometryTypeproperties aredeterminedbasedonthefeaturesprovidedtothisproperty.Ifthesourceisanempty arrayatthetimeoflayerinitialization,thengeometryTypemustbeset. ThesourceisnotupdatedaftertheFeatureLayerisinitialized.UseapplyEdits()methodtoadd,remove,andupdatefeatures fromaclient-sidefeaturelayeratruntime.OnceapplyEdits()resolvessuccessfully,usequeryFeatures() toreturnupdatedfeatures. Seealso: Addanarrayofclient-sidefeatures Example: letfeatures=[ { geometry:{ type:"point", x:-100, y:38 }, attributes:{ ObjectID:1, DepArpt:"KATL", MsgTime:Date.now(), FltId:"UAL1" } }, ... ]; //geometryTypeandspatialReferenceofthelayer //willbeinferredfromthefirstfeatureinthearray //ifithasageometry. letlayer=newFeatureLayer({ source:features,//autocastasaCollectionofnewGraphic() objectIdField:"ObjectID" }); sourceJSONObject Since:ArcGISAPIforJavaScript4.13 Thefeatureservice'smetadataJSON exposedbytheArcGISRESTAPI.Whilemostcommonlyusedproperties areexposedontheFeatureLayerclassdirectly,thispropertygivesaccesstoallinformationreturned bythefeatureservice.ThispropertyisusefulifworkinginanapplicationbuiltusinganolderversionoftheAPI whichrequiresaccesstofeatureservicepropertiesfromamorerecentversion. spatialReferenceSpatialReferenceautocast Thespatialreferenceofthelayer.Whencreatingthelayerfroma url,thespatialreferenceisreadfromtheservice. WhencreatingaFeatureLayerfromclient-sidefeatures,thispropertyis inferredfromthegeometriesofthefeaturesprovidedinthesource property. templatesFeatureTemplate[] Since:ArcGISAPIforJavaScript4.4 Anarrayoffeaturetemplatesdefinedinthefeaturelayer. SeeArcGISProsubtypesdocument. timeExtentTimeExtentautocast Since:ArcGISAPIforJavaScript4.14 Thelayer'stimeextent.Whenthelayer'suseViewTimeisfalse,thelayer instructstheviewtoshowdatafromthelayerbasedonthistimeextent. IftheuseViewTimeistrue,andbothlayerandviewtimeextentsareset,thenfeaturesthatfallwithin theintersectionoftheviewandlayertimeextentswillbedisplayed. Forexample,ifthelayer'stimeextentissettodisplayfeaturesbetween1970and1975and theviewhasatimeextentsetto1972-1980,theeffectivetimeonthefeaturelayerwillbe1972-1975. DefaultValue:null Examples: if(!layer.useViewTime){ if(layer.timeExtent){ console.log("CurrenttimeExtent:",layer.timeExtent.start,"-",layer.timeExtent.end} }else{ console.log("Thelayerwilldisplaydatawithintheview'stimeExtent."); console.log("Currentview.timeExtent:",view.timeExtent.start,"-",view.timeExtent.end} } } //setthetimeExtentonthelayeranduseViewTimefalse //Inthiscase,thelayerwillhonoritstimeExtentandignore //theview'stimeExtent constlayer=newImageryLayer({ url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/ScientificData/SeaTemperature/ImageServer", timeExtent:{ start:newDate(2014,4,18), end:newDate(2014,4,19) }, useViewTime:false }); //timeExtentissetonthelayerandtheview //Inthiscase,thelayerwilldisplayfeaturesthatfall //withintheintersectionofviewandlayertimeextents //featureswithinJan1,1976-Jan1,1981willbedisplayed constview=newMapView({ timeExtent:{ start:newDate(1976,0,1), end:newDate(2002,0,1) } }); constlayer=newFeatureLayer({ url:myUrl, timeExtent:{ start:newDate(1974,0,1), end:newDate(1981,0,1) } }); timeInfoTimeInfoautocast Since:ArcGISAPIforJavaScript4.11 TimeInfoprovidesinformationsuchasdatefieldsthatstore start andendtime foreachfeatureandthefullTimeExtent forthelayer.ThetimeInfoproperty,alongwithitsstartFieldandendFieldproperties,mustbesetatthe timeoflayerinitializationifitisbeingsetfora CSVLayer, GeoJSONLayeror FeatureLayer initializedfromclient-sidefeatures. ThefullTimeExtentfortimeInfois automaticallycalculatedbasedonitsstartFieldandendFieldproperties. ThetimeInfoparameterscannotbechangedafterthelayerisloaded. DefaultValue:null Example: //creategeojsonlayerfromusgsearthquakesgeojsonfeed constgeojsonLayer=newGeoJSONLayer({ url:"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", copyright:"USGSEarthquakes", fields:[ {"name":"mag","type":"double"}, {"name":"place","type":"string"}, {"name":"time","type":"date"},//datefield {"name":"depth","type":"double"} ], //timeInfocanbeusedtodotemporalqueries //setthestartFieldandendField. //timeExtentisautomaticallycalculatedfromthe //thestartandenddatefields //ThedatevaluesmustbeinmillisecondsnumberfromtheUNIXepochspecifiedinUTC. timeInfo:{ startField:"time" } }); timeOffsetTimeIntervalautocast Since:ArcGISAPIforJavaScript4.14 AtemporaryoffsetofthetimedatabasedonacertainTimeInterval.Thisallows userstooverlayfeaturesfromtwoormoretime-awarelayerswithdifferenttimeextents. Forexample,ifalayerhasdatarecordedfortheyear1970,anoffsetvalueof2yearswouldtemporarilyshiftthedatato 1972.Youcanthenoverlaythisdatawithdatarecordedin1972. Atimeoffsetcanbeusedfordisplaypurposesonly.Thequeryandselectionarenotaffectedbytheoffset. DefaultValue:null Example: //OffsetaCSVLayercontaininghurricanesfrom2015sothattheyappearin2019(+4years). letlayer=newCSVLayer({ url:`hurricanes-and-storms-2015.csv`, timeOffset:{ value:4, unit:"years" }, timeInfo:{ startField:"ISO_time" }, renderer:{ type:"simple", symbol:{ type:"simple-marker", size:6, color:"red", outline:{ width:0.5, color:"black" } } } }); titleString ThetitleofthelayerusedtoidentifyitinplacessuchastheLegend andLayerListwidgets. Whenloadingalayerbyserviceurl,thetitleisderivedfromtheservicename. Iftheservicehasseverallayers,thenthetitleofeachlayerwillbetheconcatenationoftheservicename andthelayername. Whenthelayerisloadedfromaportalitem,thetitleoftheportalitemwillbeusedinstead. Finally,ifalayerisloadedaspartofawebmaporawebscene,thenthetitleofthelayerasstoredinthewebmap/webscenewillbeused. typeStringreadonly ForFeatureLayerthetypeisalways"feature". typeIdFieldString Since:ArcGISAPIforJavaScript4.4 ThenameofthefieldholdingthetypeIDorsubtypesforthefeatures. SeeArcGISProsubtypesdocument. typesFeatureType[] Since:ArcGISAPIforJavaScript4.4 AnarrayofsubtypesdefinedinthefeatureserviceexposedbyArcGISRESTAPI. Eachitemincludesinformationaboutthetype,suchasthetypeID,name,anddefinitionexpression. urlString TheabsoluteURLoftheRESTendpointofthelayer,non-spatialtableorservice.TheURLmayeitherpointtoa resourceonArcGISEnterpriseorArcGISOnline. Iftheurlpointsdirectlytoaservice,thenthelayermustbespecifiedinthe layerIdproperty.IfnolayerIdisgiven,thenthefirstlayerintheservicewillbeloaded. Examples: //HostedFeatureServiceonArcGISOnline layer.url="http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/origins/FeatureServer/0"; //LayerfromMapServiceonArcGISServer layer.url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2"; //CanalsobeusedifURLpointstoserviceandnotlayer constlayer=newFeatureLayer({ //Noticethattheurldoesn'tendwith/2 url:"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer", layerId:2 }); //Non-spatialtableinSanFranciscoincidentsservice. consttable=newFeatureLayer({ url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1" }); //tablemustbeloadedsoitcanbeusedintheapp. table.load().then(function(){ //tableisloaded.readytobequeried. }); useViewTimeBoolean Since:ArcGISAPIforJavaScript4.14 Determinesifthelayerwillupdateitstemporaldatabasedontheview's timeExtent.Whenfalse,thelayerwilldisplayitstemporal databasedonthelayer'stimeExtent,regardlessofchangestotheview. Ifbothviewandlayertimeextentsaresetwhilethispropertyistrue,thenthefeaturesthatfallwithin theintersectionoftheviewandlayertimeextentswillbedisplayed. Forexample,ifalayer'stimeextentissettodisplayfeaturesbetween1970and1975and theviewhasatimeextentsetto1972-1980,theeffectivetimeonthefeaturelayerwillbe1972-1975. DefaultValue:true Example: if(featureLayer.useViewTime){ console.log("Displayingdatabetween:",view.timeExtent.start,"-",view.timeExtent.end); } versionNumberreadonly TheversionofArcGISServerinwhichthelayerispublished. Example: //Printstheversionnumbertotheconsole-e.g.10.2,10.3,10.41,etc. console.log(layer.version); visibleBoolean inherited IndicatesifthelayerisvisibleintheView.Whenfalse, thelayermaystillbeaddedtoaMap instancethatisreferencedinaview,butitsfeatureswillnotbevisibleintheview. DefaultValue:true Example: //Thelayerisnolongervisibleintheview layer.visible=false; MethodOverview Showinheritedmethods Hideinheritedmethods Name ReturnType Summary Class addAttachment() PromisemoredetailsAddsanattachmenttoafeature.moredetailsFeatureLayer applyEdits() PromisemoredetailsApplieseditstofeaturesinalayer.moredetailsFeatureLayer cancelLoad() moredetailsCancelsaload()operationifitisalreadyinprogress.moredetailsLayer clone() thismoredetailsCreatesadeepcloneofthisobject.moredetailsFeatureLayer createLayerView() PromisemoredetailsCalledbytheviews,suchasMapViewandSceneView,whenthelayerisaddedtotheMap.layerscollectionandalayerviewmustbecreatedforit.moredetailsLayer createPopupTemplate() PopupTemplatemoredetailsCreatesapopuptemplateforthelayer,populatedwithallthefieldsofthelayer.moredetailsFeatureLayer createQuery() QuerymoredetailsCreatesqueryparameterobjectthatcanbeusedtofetchfeaturesthatsatisfythelayer'sconfigurationssuchasdefinitionExpression,gdbVersion,andhistoricMoment.moredetailsFeatureLayer deleteAttachments() PromisemoredetailsDeletesattachmentsfromafeature.moredetailsFeatureLayer destroy() moredetailsDestroysthelayerandanyassociatedresources(includingitsportalItem,ifitisapropertyonthelayer).moredetailsLayer emit() BooleanmoredetailsEmitsaneventontheinstance.moredetailsLayer fetchAttributionData() PromisemoredetailsFetchescustomattributiondataforthelayerwhenitbecomesavailable.moredetailsLayer getFeatureType() FeatureTypemoredetailsReturnsaFeatureTypedescribingthefeature'stype.moredetailsFeatureLayer getField() FieldmoredetailsReturnstheFieldinstanceforafieldname(case-insensitive).moredetailsFeatureLayer getFieldDomain() DomainmoredetailsReturnstheDomainassociatedwiththegivenfieldname.moredetailsFeatureLayer hasEventListener() BooleanmoredetailsIndicateswhetherthereisaneventlistenerontheinstancethatmatchestheprovidedeventname.moredetailsLayer isFulfilled() BooleanmoredetailsisFulfilled()maybeusedtoverifyifcreatinganinstanceoftheclassisfulfilled(eitherresolvedorrejected).moredetailsLayer isRejected() BooleanmoredetailsisRejected()maybeusedtoverifyifcreatinganinstanceoftheclassisrejected.moredetailsLayer isResolved() BooleanmoredetailsisResolved()maybeusedtoverifyifcreatinganinstanceoftheclassisresolved.moredetailsLayer load() PromisemoredetailsLoadstheresourcesreferencedbythisclass.moredetailsLayer on() ObjectmoredetailsRegistersaneventhandlerontheinstance.moredetailsLayer queryAttachments() PromisemoredetailsQueryinformationaboutattachmentsassociatedwithfeatures.moredetailsFeatureLayer queryExtent() PromisemoredetailsExecutesaQueryagainstthefeatureserviceandreturnstheExtentoffeaturesthatsatisfythequery.moredetailsFeatureLayer queryFeatureCount() PromisemoredetailsExecutesaQueryagainstthefeatureserviceandreturnsthenumberoffeaturesthatsatisfythequery.moredetailsFeatureLayer queryFeatures() PromisemoredetailsExecutesaQueryagainstthefeatureserviceandreturnsaFeatureSet,whichcanbeaccessedusingthe.then()methodoncethepromiseresolves.moredetailsFeatureLayer queryObjectIds() PromisemoredetailsExecutesaQueryagainstthefeatureserviceandreturnsanarrayofObjectIDsforfeaturesthatsatisfytheinputquery.moredetailsFeatureLayer queryRelatedFeatures() PromisemoredetailsExecutesaRelationshipQueryagainstthefeatureserviceandreturnsFeatureSetsgroupedbysourcelayerortableobjectIds.moredetailsFeatureLayer queryRelatedFeaturesCount() PromisemoredetailsExecutesaRelationshipQueryagainstthefeatureserviceandwhenresolved,itreturnsanobjectcontainingkeyvaluepairs.moredetailsFeatureLayer queryTopFeatureCount() PromisemoredetailsExecutesaTopFeaturesQueryagainstafeatureserviceandreturnsthecountoffeaturesorrecordsthatsatisfythequery.moredetailsFeatureLayer queryTopFeatures() PromisemoredetailsExecutesaTopFeaturesQueryagainstafeatureserviceandreturnsaFeatureSetoncethepromiseresolves.moredetailsFeatureLayer queryTopFeaturesExtent() PromisemoredetailsExecutesaTopFeaturesQueryagainstafeatureserviceandreturnstheExtentoffeaturesthatsatisfythequery.moredetailsFeatureLayer queryTopObjectIds() PromisemoredetailsExecutesaTopFeaturesQueryagainstafeatureserviceandreturnsanarrayofObjectIDsoffeaturesthatsatisfythequery.moredetailsFeatureLayer refresh() moredetailsFetchesallthedataforthelayer.moredetailsFeatureLayer save() PromisemoredetailsSavesthelayertoitsexistingportaliteminthePortalauthenticatedwithintheuser'scurrentsession.moredetailsFeatureLayer saveAs() PromisemoredetailsSavesthelayertoanewportaliteminthePortalauthenticatedwithintheuser'scurrentsession.moredetailsFeatureLayer updateAttachment() PromisemoredetailsUpdatesanexistingattachmentforafeature.moredetailsFeatureLayer when() Promisemoredetailswhen()maybeleveragedonceaninstanceoftheclassiscreated.moredetailsLayer MethodDetails addAttachment(feature,attachment){Promise} Since:ArcGISAPIforJavaScript4.9 Addsanattachmenttoafeature.Thisoperationisavailableonlyifthelayer's capabilities.data.supportsAttachmentissettotrue. Parameters: feature Graphic Featuretowhichtheattachmentistobeadded. attachment HTMLFormElement|FormData HTMLformthatcontainsafileuploadfieldpointingtothefiletobeaddedasanattachment. Returns: Type Description Promise Whenresolved,aFeatureEditResult objectisreturned.FeatureEditResultindicateswhetherornottheeditwassuccessful.Ifsuccessful,theobjectIdoftheresultistheIdof thenewattachment.Ifunsuccessful,italsoincludesanerrornameanderrormessage. Seealso: capabilities.data.supportsAttachment Example: view.when(function(){ view.on("click",function(event){ view.hitTest(event).then(function(response){ constfeature=response.results[0].graphic; //Theformisdefinedasbelowinthehtml. //Forenterpriseservices: //1.Fileinputnamemustbe"attachment" // //Selectafile: // constattachmentForm=document.getElementById("attachmentForm"); constformData=newFormData(attachmentForm); //Forenterpriseservices-addinputwithname:fandvalue:json formData.append("f","json"); constform=newFormData(); form.set("attachment",file); form.append("f","json") letform=document.getElementById("myForm"); //Addanattachmenttotheclickedfeature. //Theattachmentistakenfromtheform. layer.addAttachment(feature,form).then(function(result){ console.log("attachmentadded:",result); }) .catch(function(err){ console.log("attachmentaddingfailed:",err); }); }); }); }); applyEdits(edits,options){Promise} Applieseditstofeaturesinalayer.Newfeaturescanbecreatedandexistingfeaturescanbeupdatedordeleted.Featuregeometriesand/orattributesmaybemodified. Onlyapplicabletolayersinafeatureservice andclient-sidefeaturessetthroughthelayer'ssource.Attachmentscanalsobeadded,updatedordeleted. Ifclient-sidefeaturesareadded,removedorupdatedatruntimeusingapplyEdits()thenusequeryFeatures()toreturnupdatedfeatures. WhencallingtheapplyEditsmethodonaservicethatdoesnothaveverticalcoordinatesysteminformation, thez-valuesofthegeometriesintheeditsobjectwillautomaticallybeconvertedtomatchthespatialreferenceofthelayer. Example:Theservicehasahorizontalspatialreferencewithfeetunits,andapplyEdits()iscalledwithz-valuesbasedonmeterunits, thenthemethodwillautomaticallyconvertthezvaluesfrommetertofeetunits. Asofversion4.17,usingapplyEditstoaddgeometrieswithz-valuestoaFeatureLayerwithhasZ:falsenolongersilentlydropsthez-valueandnowthrowsanerror. Parameters: Specification: edits Object Objectcontainingfeaturesandattachmentstobeadded,updatedordeleted. Specification: addFeatures Graphic[]|Collection optional Anarrayora collectionoffeaturestobeadded. Valuesofnonnullablefieldsmustbeprovidedwhenaddingnewfeatures.Datefieldsmusthave numericvalues representinguniversaltime. updateFeatures Graphic[]|Collection optional Anarrayora collectionoffeaturestobeupdated.Eachfeaturemusthavevalid objectId.Valuesofnonnullablefieldsmustbeprovidedwhenupdatingfeatures.Datefieldsmusthave numericvalues representinguniversaltime. deleteFeatures Graphic[]|Collection|Object[] optional Anarrayora collectionoffeatures,oranarrayofobjectswithobjectIdorglobalIdofeachfeaturetobedeleted. Whenanarrayorcollectionoffeaturesispassed,eachfeaturemusthaveavalidobjectId.Whenanarrayofobjectsisused, eachobjectmusthaveavalidvaluesetforobjectIdorglobalIdproperty. addAttachments AttachmentEdit[] optional Anarrayofattachmentstobeadded.Appliesonlywhentheoptions.globalIdUsed parameterissettotrue.UsermustprovideglobalIdsforallattachmentstobeadded. updateAttachments AttachmentEdit[] optional Anarrayofattachmentstobeupdated.Appliesonlywhentheoptions.globalIdUsed parameterissettotrue.UsermustprovideglobalIdsforallattachmentstobeupdated. deleteAttachments String[] optional AnarrayofglobalIdsforattachmentstobedeleted.Appliesonlywhentheoptions.globalIdUsed parameterissettotrue. options Object optional Additionaleditoptionstospecifywheneditingfeaturesorattachments. Specification: gdbVersion String optional Thegeodatabaseversiontoapplytheedits.Thisparameterappliesonlyifthe capabilities.data.isVersionedpropertyofthelayeristrue.IfthegdbVersionparameterisnotspecified,editsaremadetothepublishedmap’sversion. returnEditMoment Boolean optional Indicateswhethertheeditresultsshouldreturnthetimeeditswereapplied.Iftrue,thefeatureservicewillreturn thetimeeditswereappliedintheeditresult'seditMomentproperty.OnlyapplicablewithArcGISServerservicesonly.Thisoptionwasaddedattheversion4.20. returnServiceEditsOption String optional Ifsettooriginal-and-current-features,theEditedFeatureResultparameterwillbeincluded intheapplyEditsresponse.Itcontainsalleditedfeaturesparticipatingincompositerelationshipsinadatabaseasresultofeditingafeature.Notethatevenfordeletions,thegeometryandattributes ofthedeletedfeaturearereturned.Theoriginal-and-current-featuresoptionisonlyvalidwhenrollbackOnFailureEnabledistrue.Thedefaultvalueisnone,whichwillnotincludethe EditedFeatureResultparameterintheresponse.ThisisonlyapplicablewithArcGISServerservicesonly.Thisoptionwasaddedattheversion4.20. PossibleValues:"none"|"original-and-current-features" rollbackOnFailureEnabled Boolean optional Indicateswhethertheeditsshouldbeappliedonlyifallsubmittededitssucceed. Iffalse,theserverwillapplytheeditsthatsucceedevenifsomeofthesubmittededitsfail.Iftrue,theserverwillapplytheedits onlyifalleditssucceed.Thelayer'scapabilities.editing.supportsRollbackOnFailurepropertymustbetrueifusingthisparameter. IfsupportsRollbackOnFailureisfalseforalayer,thenrollbackOnFailureEnabledwillalwaysbetrue,regardlessofhowtheparameterisset. globalIdUsed Boolean optional IndicateswhethertheeditscanbeappliedusingglobalIdsoffeaturesorattachments. Thisparameterappliesonlyifthelayer'scapabilities.editing.supportsGlobalIdpropertyistrue. Whenfalse,globalIdssubmittedwiththefeaturesareignoredandtheserviceassignsnewglobalIds tothenewfeatures.Whentrue,theglobalIdsmustbesubmittedwiththenewfeatures.Whenupdatingexistingfeatures,iftheglobalIdUsedis false,theobjectIdsofthefeaturestobeupdatedmustbeprovided.IftheglobalIdUsedistrue,globalIdsoffeaturestobeupdatedmustbeprovided. Whendeletingexistingfeatures,setthispropertytofalseasdeletesoperationonlyacceptsobjectIdsatthecurrentversionoftheAPI. Whenadding,updatingordeletingattachments,globalIdUsedparametermustbesettotrueandtheattachmentglobalIdmustbeset. Fornewattachments,theusermustprovideglobalIds.Inorderforanattachmenttobeupdatedordeleted,clientsmustincludeitsglobalId. AttachmentsarenotsupportedinaneditpayloadwhenglobalIdUsedisfalse. //addanimageattachmentstofeatures functionaddAttachment(selectedFeature){ constblob=newBlob(byteArrays,{type:"image/png"}); addAttachments.push({ feature:selectedFeature, attachment:{ globalId:"8c4d6085-a33c-42a0-8e11-21e9528bca0d", name:"brokenLight", data:blob } }); constedits={ addAttachments:addAttachments }; constoptions={ //globalIdUsedhastobetruewhenadding,updatingordeletingattachments globalIdUsed:true, rollbackOnFailureEnabled:true }; featureLayer.applyEdits(edits,options).then(function(results){ console.log("editsadded:",results); }); } Returns: Type Description Promise Whenresolved,anEditsResult objectisreturned. Seealso: Sample-Editfeatures Example: functionaddFeature(geometry){ constattributes={}; attributes["Description"]="Thisisthedescription"; attributes["Address"]="380NewYorkSt"; //Date.now()returnsnumberofmillisecondselapsed //since1January197000:00:00UTC. attributes["Report_Date"]=Date.now(); constaddFeature=newGraphic({ geometry:geometry, attributes:attributes }); constdeleteFeatures=[ {objectId:467}, {objectId:500} ]; //orspecifyglobalIdsoffeaturestobedeleted //constdeleteFeature=[ //{globalId:"18633204-1801-4d35-a73a-174563608ad9"} //]; constpromise=featureLayer.applyEdits({ addFeatures:[addFeature], deleteFeatures:deleteFeatures }); } cancelLoad()inherited Cancelsaload()operationifitisalreadyinprogress. clone(){this} Createsadeepcloneofthisobject.Anypropertiesthatstorevaluesbyreferencewillbe assignedcopiesofthereferencedvaluesontheclonedinstance. Returns: Type Description this Adeepcloneoftheclassinstancethatinvokedthismethod. createLayerView(view,options){Promise}inherited Calledbytheviews,suchasMapViewand SceneView,whenthelayerisaddedtothe Map.layerscollectionandalayerviewmust becreatedforit.Thismethodisusedinternallyandthereisnousecaseforinvokingitdirectly. Parameters: view * Theparentview. options Object optional Anobjectspecifyingadditionaloptions.Seethe objectspecificationtablebelowfortherequiredpropertiesofthisobject. Specification: signal AbortSignal optional Asignaltoabortthecreationofthelayerview. Returns: Type Description Promise ResolveswithaLayerViewinstance. Seealso: Sample-CustomWebGLlayerview createPopupTemplate(options){PopupTemplate} Since:ArcGISAPIforJavaScript4.11 Createsapopuptemplateforthelayer,populatedwithallthefieldsofthelayer. Parameter: options CreatePopupTemplateOptions optional Optionsforcreatingthepopuptemplate. Returns: Type Description PopupTemplate Thepopuptemplate,ornullifthelayerdoesnot haveanyfields. createQuery(){Query} Createsqueryparameterobjectthatcanbeusedtofetchfeaturesthat satisfythelayer'sconfigurationssuchasdefinitionExpression, gdbVersion,andhistoricMoment. ItwillreturnZandMvaluesbasedonthelayer'sdatacapabilities. Itsetsthequeryparameter'soutFieldspropertyto["*"]. Theresultswillincludegeometriesoffeaturesandvaluesforall availablefieldsfor client-sidequeries orallfieldsinthelayerforserversidequeries. Returns: Type Description Query Thequeryobjectrepresentingthelayer'sdefinitionexpression andotherconfigurations. Seealso: Sample-QueryfeaturesfromaFeatureLayer Examples: //thissnippetshowsthequeryparameterobjectthatisreturned //fromFeatureLayer.createQuery(). constqueryParams=newQuery(); constdataCapabilities=layer.get("capabilities.data"); queryParams.gdbVersion=layer.gdbVersion; queryParams.historicMoment=layer.historicMoment; queryParams.returnGeometry=true; if(dataCapabilities){ if(dataCapabilities.supportsZ&&layer.returnZ!=null){ queryParams.returnZ=layer.returnZ; } if(dataCapabilities.supportsM&&layer.returnM!=null){ queryParams.returnM=layer.returnM; } } queryParams.outFields=["*"]; queryParams.where=layer.definitionExpression||"1=1"; queryParams.multipatchOption=layer.geometryType==="multipatch"?"xyFootprint":null; //Getaqueryobjectforthelayer'scurrentconfiguration //queryParams.outFieldswillbesetto["*"]togetvalues //forallavailablefields. constqueryParams=layer.createQuery(); //setageometryforfilteringfeaturesbyaregionofinterest queryParams.geometry=extentForRegionOfInterest; //Addtothelayer'scurrentdefinitionExpression queryParams.where=queryParams.where+"ANDTYPE='Extreme'"; //querythelayerwiththemodifiedparamsobject layer.queryFeatures(queryParams).then(function(results){ //printsthearrayofresultgraphicstotheconsole console.log(results.features); }); deleteAttachments(feature,attachmentIds){Promise} Since:ArcGISAPIforJavaScript4.9 Deletesattachmentsfromafeature.Thisoperationisavailableonlyifthelayer's capabilities.data.supportsAttachmentissettotrue. Parameters: feature Graphic Featurecontainingattachmentstobedeleted. attachmentIds Number[] Idsoftheattachmentstobedeleted. Returns: Type Description Promise Whenresolved,anarrayofFeatureEditResults isreturned.FeatureEditResultindicateswhetherornottheeditwassuccessful.Ifsuccessful,theobjectIdoftheresultistheIdof thenewattachment.Ifunsuccessful,italsoincludesanerrornameanderrormessage. Seealso: capabilities.data.supportsAttachment destroy()inherited Since:ArcGISAPIforJavaScript4.17 Destroysthelayerandanyassociatedresources(includingitsportalItem,ifitisapropertyonthelayer). Thelayercannolongerbeusedonceithasbeendestroyed. ThedestroyedlayerwillberemovedfromitsparentobjectlikeMap,WebMap,WebScene, Basemap,Ground,orGroupLayer. Seealso: Map.destroy() WebMap.destroy() WebScene.destroy() Basemap.destroy() Ground.destroy() PortalItem.destroy() emit(type,event){Boolean}inherited Since:ArcGISAPIforJavaScript4.5 Emitsaneventontheinstance.Thismethodshouldonlybeusedwhencreatingsubclassesofthisclass. Parameters: type String Thenameoftheevent. event Object optional Theeventpayload. Returns: Type Description Boolean trueifalistenerwasnotified fetchAttributionData(){Promise}inherited Fetchescustomattributiondataforthelayerwhenitbecomesavailable. Returns: Type Description Promise Resolvestoanobjectcontainingcustomattributiondataforthelayer. getFeatureType(feature){FeatureType} Since:ArcGISAPIforJavaScript4.7 ReturnsaFeatureTypedescribingthefeature'stype. ThisisapplicableifthelayercontainingthefeaturehasatypeIdField. Parameter: feature Graphic Afeaturefromthislayer. Returns: Type Description FeatureType TheFeatureTypedescribingthefeature'stype. getField(fieldName){Field} Since:ArcGISAPIforJavaScript4.11 ReturnstheFieldinstanceforafieldname(case-insensitive). Parameter: fieldName String Nameofthefield. Returns: Type Description Field thematchingfieldorundefined Seealso: fields getFieldDomain(fieldName,options){Domain} ReturnstheDomainassociatedwiththegivenfieldname.Thedomaincanbeeithera CodedValueDomainorRangeDomain. Parameters: fieldName String Nameofthefield. options Object optional Anobjectspecifyingadditionaloptions.Seethe objectspecificationtablebelowfortherequiredpropertiesofthisobject. Specification: feature Graphic ThefeaturetowhichtheDomainisassigned. Returns: Type Description Domain TheDomainobjectassociatedwiththegivenfieldnameforthegivenfeature. Example: //Getarangedomainassociatedwiththefirstfeature //returnedfromqueryFeatures(). featureLayer.queryFeatures(query).then(function(results){ constdomain=featureLayer.getFieldDomain("Height",{feature:results.features[0]}); console.log("domain",domain) }); hasEventListener(type){Boolean}inherited Indicateswhetherthereisaneventlistenerontheinstancethatmatches theprovidedeventname. Parameter: type String Thenameoftheevent. Returns: Type Description Boolean Returnstrueiftheclasssupportstheinputevent. isFulfilled(){Boolean}inherited isFulfilled()maybeusedtoverifyifcreatinganinstanceoftheclassisfulfilled(eitherresolvedorrejected). Ifitisfulfilled,truewillbereturned. Returns: Type Description Boolean Indicateswhethercreatinganinstanceoftheclasshasbeenfulfilled(eitherresolvedorrejected). isRejected(){Boolean}inherited isRejected()maybeusedtoverifyifcreatinganinstanceoftheclassisrejected. Ifitisrejected,truewillbereturned. Returns: Type Description Boolean Indicateswhethercreatinganinstanceoftheclasshasbeenrejected. isResolved(){Boolean}inherited isResolved()maybeusedtoverifyifcreatinganinstanceoftheclassisresolved. Ifitisresolved,truewillbereturned. Returns: Type Description Boolean Indicateswhethercreatinganinstanceoftheclasshasbeenresolved. load(signal){Promise}inherited Loadstheresourcesreferencedbythisclass.Thismethodautomatically executesforaViewandalloftheresources itreferencesinMapiftheviewisconstructedwith amapinstance. Thismethodmustbecalledbythedeveloperwhenaccessingaresourcethatwillnotbe loadedinaView. Theload()methodonlytriggerstheloadingoftheresourcethefirsttimeitiscalled.Thesubsequentcallsreturnthesamepromise. It'spossibletoprovideasignaltostopbeinginterestedintoaLoadableinstanceloadstatus. Whenthesignalisaborted,theinstancedoesnotstopitsloadingprocess,onlycancelLoadcanabortit. Parameter: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Resolveswhentheresourceshaveloaded. on(type,listener){Object}inherited Registersaneventhandlerontheinstance.Callthismethodtohookaneventwithalistener. Parameters: type String|String[] Aneventoranarrayofeventstolistenfor. listener Function Thefunctiontocallwhentheeventfires. Returns: Type Description Object Returnsaneventhandlerwitharemove()methodthatshouldbecalledtostoplisteningfortheevent(s). Property Type Description remove Function Whencalled,removesthelistenerfromtheevent. Example: view.on("click",function(event){ //eventistheeventhandlereturnedaftertheeventfires. console.log(event.mapPoint); }); queryAttachments(attachmentQuery,options){Promise} Since:ArcGISAPIforJavaScript4.9 Queryinformationaboutattachmentsassociatedwithfeatures.Itwillreturnanerrorifthelayer's capabilities.data.supportsAttachmentpropertyisfalse. Attachmentsformultiplefeaturescanbequeriedifthelayer's capabilities.operations.supportsQueryAttachmentsistrue. KnownLimitations Whenthelayer'scapabilities.operations.supportsQueryAttachmentspropertyis false,AttachmentQuery.objectIdspropertyonlyacceptsasingle objectId. Parameters: attachmentQuery AttachmentQuery autocast Autocastsfrom Object Specifiestheattachmentparametersforquery. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsanobjectcontaining AttachmentInfosgroupedbythesource featureobjectIds. Seealso: capabilities.data.supportsAttachment capabilities.operations.supportsQueryAttachments Example: featureLayer.when(function(){ //queryObjectIdsforallfeatureswithinthelayer featureLayer.queryObjectIds().then(function(objectIds){ //Defineparametersforqueryingattachments, //queryfeatureswhereobjectIdsarelessthan735, //andonlyqueryjpegattachmentsforthesefeatures. letattachmentQuery={ objectIds:objectIds, definitionExpression:"OBJECTID<735", attachmentTypes:["image/jpeg"] }; //OnlypassinoneobjectIdforattachmentQuery.objectIds //ifthelayer'scapabilities.operations.supportsQueryAttachmentsisfalse featureLayer.queryAttachments(attachmentQuery).then(function(attachments){ //Printoutallreturnedattachmentinfostotheconsole. attachmentQuery.objectIds.forEach(function(objectId){ if(attachments[objectId]){ letattachment=attachments[objectId]; console.group("attachmentfor",objectId); attachment.forEach(function(item){ console.log("attachmentid",item.id); console.log("contenttype",item.contentType); console.log("name",item.name); console.log("size",item.size); console.log("url",item.url); console.groupEnd(); }); } }); }) .catch(function(error){ console.log("attachmentqueryerror",error); }) }); }); queryExtent(query,options){Promise} ExecutesaQueryagainstthefeatureserviceand returnstheExtentoffeaturesthatsatisfythequery.Ifno parametersarespecified,thentheextentandcountofallfeatures satisfyingthelayer'sconfiguration/filtersarereturned. Toqueryfortheextentoffeatures/graphicsavailabletoorvisibleinthe Viewontheclientratherthanmakingaserver-sidequery,youmust usethe FeatureLayerView.queryExtent() method. Parameters: query Query autocast optional Autocastsfrom Object Specifiestheattributesandspatial filterofthequery.Ifnoparametersarespecified,thentheextentandcountofallfeatures satisfyingthelayer'sconfiguration/filtersarereturned. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnstheextentandcountofthefeatures thatsatisfytheinputquery.Seetheobjectspecificationtablebelowfordetails. Property Type Description count Number Thenumberoffeaturesthatsatisfytheinputquery. extent Extent Theextentofthefeaturesthatsatisfythequery. Examples: //Queriesfortheextentofallfeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryExtent().then(function(results){ //gototheextentoftheresultssatisfyingthequery view.goTo(results.extent); }); constlayer=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); constquery=newQuery(); query.where="region='SouthernCalifornia'"; layer.queryExtent(query).then(function(results){ view.goTo(results.extent);//gototheextentoftheresultssatisfyingthequery }); queryFeatureCount(query,options){Promise} ExecutesaQueryagainstthefeatureserviceand returnsthenumberoffeaturesthatsatisfythequery.Ifnoparametersarespecified, thetotalnumberoffeaturessatisfyingthelayer'sconfiguration/filtersisreturned. Toqueryforthecountoffeatures/graphicsavailabletoorvisibleinthe Viewontheclientratherthanmakingaserver-sidequery,youmust usethe FeatureLayerView.queryFeatureCount() method. Parameters: query Query autocast optional Autocastsfrom Object Specifiestheattributesand spatialfilterofthequery.Ifnoparametersarespecified,thetotalnumberoffeatures satisfyingthelayer'sconfiguration/filtersisreturned. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsanthenumberoffeaturessatisfyingthequery. Examples: //Queriesforthecountofallfeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryFeatureCount().then(function(numFeatures){ //printsthetotalcounttotheconsole console.log(numFeatures); }); constlayer=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); constquery=newQuery(); query.where="region='SouthernCalifornia'"; layer.queryFeatureCount(query).then(function(numResults){ console.log(numResults);//printsthenumberofresultssatisfyingthequery }); queryFeatures(query,options){Promise} ExecutesaQueryagainstthefeatureserviceandreturnsa FeatureSet,whichcanbeaccessedusingthe.then()method oncethepromiseresolves. AFeatureSetcontainsanarrayofGraphic features.Seethequerying sectionformoreinformationonhowtoqueryfeaturesfromalayer. Toqueryfeatures/graphicsavailabletoorvisibleinthe Viewontheclientratherthanmakingaserver-sidequery,youmust usethe FeatureLayerView.queryFeatures() method. Whenqueryingaservicewithz-valuesandnoverticalcoordinatesysteminformation, thez-valueswillautomaticallybeconvertedtomatchtheoutSpatialReferenceunits. Example:TheservicehasahorizontalspatialreferenceusingfeetunitsandthequeryismadewithoutSpatialReference basedonmeterunits,thenqueryFeatures()automaticallyconvertsthevaluesfromfeettometerunits. Parameters: query Query autocast optional Autocastsfrom Object Specifiestheattributesandspatial filterofthequery.Ifnoparametersarespecified,thenallfeaturessatisfyingthelayer's configuration/filtersarereturned. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,aFeatureSetcontaining anarrayofgraphicfeaturesisreturned. Seealso: Sample-QueryfeaturesfromaFeatureLayer Queryandfilterguide Examples: //Queriesforallthefeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryFeatures().then(function(results){ //printsthearrayofresultgraphicstotheconsole console.log(results.features); }); constlayer=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); constquery=newQuery(); query.where="STATE_NAME='Washington'"; query.outSpatialReference={wkid:102100}; query.returnGeometry=true; query.outFields=["CITY_NAME"]; layer.queryFeatures(query).then(function(results){ console.log(results.features);//printsthearrayoffeaturestotheconsole }); //Getaqueryobjectforthelayer'scurrentconfiguration constqueryParams=layer.createQuery(); //setageometryforfilteringfeaturesbyaregionofinterest queryParams.geometry=extentForRegionOfInterest; //Addtothelayer'scurrentdefinitionExpression queryParams.where=queryParams.where+"ANDTYPE='Extreme'"; //querythelayerwiththemodifiedparamsobject layer.queryFeatures(queryParams).then(function(results){ //printsthearrayofresultgraphicstotheconsole console.log(results.features); }); constlayer=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); //queryallfeaturesfromthelayerandonlyreturn //attributesspecifiedinoutFields. constquery={//autocastsasQuery where:"1=1",//selectallfeatures returnGeometry:false, outFields:["State_Name","City_Name","pop2010"] }; layer.queryFeatures(query).then(function(results){ console.log(results.features);//printsthearrayoffeaturestotheconsole }); queryObjectIds(query,options){Promise} ExecutesaQueryagainstthefeatureserviceandreturnsan arrayofObjectIDsforfeaturesthatsatisfytheinputquery.Ifnoparametersarespecified, thentheObjectIDsofallfeaturessatisfyingthelayer'sconfiguration/filtersarereturned. ToqueryforObjectIDsoffeatures/graphicsavailabletoorvisibleinthe Viewontheclientratherthanmakingaserver-sidequery,youmust usethe FeatureLayerView.queryObjectIds() method. Parameters: query Query autocast optional Autocastsfrom Object Specifiestheattributesandspatial filterofthequery.Ifnoparametersarespecified,thentheObjectIDsofallfeatures satisfyingthelayer'sconfiguration/filtersarereturned. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsanarrayofnumbersrepresentingtheobjectIDsofthefeatures satisfyingthequery. Examples: //QueriesforalltheObjectIDsoffeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryObjectIds().then(function(results){ //printsthearrayofObjectIDstotheconsole console.log(results); }); constlayer=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); constquery=newQuery(); query.where="region='SouthernCalifornia'"; layer.queryObjectIds(query).then(function(ids){ console.log(ids);//anarrayofobjectIDs }); queryRelatedFeatures(relationshipQuery,options){Promise} Since:ArcGISAPIforJavaScript4.9 ExecutesaRelationshipQueryagainstthefeatureserviceand returnsFeatureSetsgroupedbysourcelayerortableobjectIds. Parameters: relationshipQuery RelationshipQuery autocast Autocastsfrom Object Specifiesrelationshipparameters forqueryingrelatedfeaturesorrecordsfromalayeroratable. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsFeatureSetsgrouped bysourcelayer/tableobjectIds.EachFeatureSetcontainsanarrayofGraphic featuresincludingthevaluesofthefieldsrequestedbytheuser. Seealso: FeatureLayer.relationships Sample-QueryRelatedFeatures Example: constobjectIds=[385,416]; //relationshipqueryparameter constquery={ outFields:["*"], relationshipId:relationshipId, objectIds:objectIds } //queryrelatedfeaturesforgivenobjectIds featureLayer.queryRelatedFeatures(query).then(function(result){ objectIds.forEach(function(objectId){ //printouttheattributesofrelatedfeaturesiftheresult //isreturnedforthespecifiedobjectId if(result[objectId]){ console.group("relationshipforfeature:",objectId) result[objectId].features.forEach(function(feature){ console.log("attributes",JSON.stringify(feature.attributes)); }); console.groupEnd(); } }); }).catch(function(error){ console.log("errorfromqueryRelatedFeatures",error); }); queryRelatedFeaturesCount(relationshipQuery,options){Promise} Since:ArcGISAPIforJavaScript4.17 ExecutesaRelationshipQueryagainstthefeatureserviceand whenresolved,itreturnsanobjectcontainingkeyvaluepairs.KeyinthiscaseistheobjectId ofthefeatureandvalueisthenumberofrelatedfeaturesassociatedwiththefeature. Parameters: relationshipQuery RelationshipQuery autocast Autocastsfrom Object Specifiesrelationshipparameters forqueryingrelatedfeaturesorrecordsfromalayeroratable. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsanobjectcontainingkeyvaluepairs.KeyinthiscaseistheobjectId ofthefeatureandvalueisthenumberofrelatedfeatures. Seealso: FeatureLayer.relationships Sample-QueryRelatedFeatures Example: constobjectIds=[385,416]; //relationshipqueryparameter constquery={ outFields:["*"], relationshipId:relationshipId, objectIds:objectIds } //queryrelatedfeaturesforgivenobjectIds featureLayer.queryRelatedFeaturesCount(query).then(function(count){ console.log("queryRelatedFeaturesCount",count); //thiswillprintout //{385:91,416:23} }).catch(function(error){ console.log("errorfromqueryRelatedFeatures",error); }); queryTopFeatureCount(topFeaturesQuery,options){Promise} Since:ArcGISAPIforJavaScript4.20 ExecutesaTopFeaturesQueryagainstafeatureserviceandreturns thecountoffeaturesorrecordsthatsatisfythequery. KnownLimitations Currently,thequeryTopFeatureCountisonlysupportedwithserver-sideFeatureLayers. Parameters: topFeaturesQuery TopFeaturesQuery autocast Autocastsfrom Object Specifiestheattributes,spatial,temporal,andtop filterofthequery.ThetopFilterparametermustbeset. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsthenumberoffeaturessatisfyingthequery. Seealso: Sample-QueryfeaturesfromaFeatureLayer Queryandfilterguide TopFeaturesQuery TopFilter Example: //setthequerytoreturnacount //offeaturesthathasmostsalesgroupedbyregions. //topquerywillrunagainstallfeaturesavailableintheservice constquery=newTopFeaturesQuery({ topFilter:newTopFilter({ topCount:1, groupByFields:["Region"], orderByFields:["SalesDESC"] }) }); featureLayer.queryTopFeatureCount(query) .then(function(response){ //returnsthenumberofthefeaturesthathavethemostsalesbyregion. }); queryTopFeatures(topFeaturesQuery,options){Promise} Since:ArcGISAPIforJavaScript4.20 ExecutesaTopFeaturesQueryagainstafeatureserviceandreturnsa FeatureSetoncethepromiseresolves. TheFeatureSetcontainsanarrayoftopfeatures groupedandorderedbyspecifiedfields.Forexample,youcancallthismethodtoquerytopthreecountiesgrouped bystatenameswhileorderingthembasedontheirpopulationsinadescendingorder. KnownLimitations Currently,thequeryTopFeaturesisonlysupportedwithserver-sideFeatureLayers. Parameters: topFeaturesQuery TopFeaturesQuery autocast Autocastsfrom Object Specifiestheattributes,spatial,temporal,andtop filterofthequery.ThetopFilterparametermustbeset. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsaFeatureSetcontaining anarrayoffeaturesthataregroupedandorderedspecifiedfields. Seealso: Sample-QueryfeaturesfromaFeatureLayer Queryandfilterguide TopFeaturesQuery TopFilter Example: //Querythemostvisitednationalparksineachstate //andorderthembythemostvisited //querywillrunagainstallfeaturesavailableintheservice constquery=newTopFeaturesQuery({ outFields:["State,TOTAL,Park"], topFilter:newTopFilter({ topCount:1, groupByFields:["State"], orderByFields:["TOTALDESC"] }) }); featureLayer.queryTopFeatures(query) .then(function(response){ //returnsafeaturesetwithfeaturescontainingthemostvisited //nationalparkineachstateorderedbythenumberofvisits. //Thefollowingattributesarereturnedaswell:State,TOTAL,Park }); queryTopFeaturesExtent(topFeaturesQuery,options){Promise} Since:ArcGISAPIforJavaScript4.20 ExecutesaTopFeaturesQueryagainstafeatureserviceandreturns theExtentoffeaturesthatsatisfythequery. KnownLimitations Currently,thequeryTopFeaturesExtentisonlysupportedwithserver-sideFeatureLayers. Parameters: topFeaturesQuery TopFeaturesQuery autocast Autocastsfrom Object Specifiestheattributes,spatial,temporal,andtop filterofthequery.ThetopFilterparametermustbeset. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnstheextentandcountofthefeatures thatsatisfytheinputquery.Seetheobjectspecificationtablebelowfordetails. Property Type Description count Number Thenumberoffeaturesthatsatisfythequery. extent Extent Theextentoffeaturesthatsatisfythequery. Seealso: Sample-QueryfeaturesfromaFeatureLayer Queryandfilterguide TopFeaturesQuery TopFilter Example: //Getthecountandextentofthethreehighestmagnitudeearthquakes //ineachregion. constquery=newTopFeaturesQuery({ where:"mag>=6", geometry:studyExtent, topFilter:newTopFilter({ topCount:3, groupByFields:["region"], orderByFields:["magDESC"] }) }); featureLayer.queryTopFeaturesExtent(query) .then(function(response){ //returnsthecountandextentoftopthreeearthquakeswithineachregion }); queryTopObjectIds(topFeaturesQuery,options){Promise} Since:ArcGISAPIforJavaScript4.20 ExecutesaTopFeaturesQueryagainstafeatureserviceandreturnsan arrayofObjectIDsoffeaturesthatsatisfythequery. KnownLimitations Currently,thequeryTopObjectIdsisonlysupportedwithserver-sideFeatureLayers. Parameters: topFeaturesQuery TopFeaturesQuery autocast Autocastsfrom Object Specifiestheattributes,spatial,temporal,andtop filterofthequery.ThetopFilterparametermustbeset. options Object optional Anobjectwiththefollowingproperties. Specification: signal AbortSignal optional Signalobjectthatcanbeusedtoaborttheasynchronoustask. ThereturnedpromisewillberejectedwithanErrornamedAbortErrorwhenanabortissignaled. SeealsoAbortControllerformoreinformationonhowtoconstructacontrollerthatcanbeusedtodeliverabortsignals. Returns: Type Description Promise Whenresolved,returnsanarrayofnumbersrepresentingtheobjectIDsoffeatures satisfyingthequery. Seealso: Sample-QueryfeaturesfromaFeatureLayer Queryandfilterguide TopFeaturesQuery TopFilter Example: //GettheobjectIdstopthreeearthquakes //groupedbyregionsandorderedbytheirmagnitudelevels //topquerywillonlyrunagainstearthquakesthathavemag>=6. constquery=newTopFeaturesQuery({ where:"mag>=6", topFilter:newTopFilter({ topCount:3, groupByFields:["region"], orderByFields:["magDESC"] }) }); featureLayer.queryTopObjectIds(query) .then(function(response){ //returnsanarrayofobjectidsoftopthreeearthquakeswithineachregion }); refresh() Since:ArcGISAPIforJavaScript4.6 Fetchesallthedataforthelayer.ThedataisonlyupdatedifthelastEditDateinthelayer'smetadataisdifferentfrom thelastEditDatefield.IfthelastEditDatemetadatainfoisnotavailable,theFeatureLayerrefreshesunconditionally. Seealso: refreshInterval refreshevent save(options){Promise} Since:ArcGISAPIforJavaScript4.24 SavesthelayertoitsexistingportaliteminthePortal authenticatedwithintheuser'scurrentsession.Ifthelayerisnotsavedtoa PortalItem,thenyoushouldusesaveAs. Parameters: Specification: options Object optional Variousoptionsforsavingthelayer. Specification: validationOptions Object optional Optionsforvalidatingthesaveoperation. Specification: ignoreUnsupported Boolean optional Indicateswhethertoignoresavingunsupportedlayersorlayerswithunsupportedcontent,suchasunsupportedsymbology. Returns: Type Description Promise Whenresolved,returnstheportalitemtowhichthelayerissaved. Example: constportalItem=awaitlayer.save(); saveAs(portalItem,options){Promise} Since:ArcGISAPIforJavaScript4.24 SavesthelayertoanewportaliteminthePortal authenticatedwithintheuser'scurrentsession. Parameters: Specification: portalItem PortalItem autocast Autocastsfrom Object Theportalitemtowhichthelayerwillbesaved. options Object optional Variousoptionsforsavingthelayer. Specification: folder PortalFolder optional Theportalfolderwherethelayer'sportalitemwillbesaved. validationOptions Object optional Optionsforvalidatingthesaveoperation. Specification: ignoreUnsupported Boolean optional Indicateswhethertoignoresavingunsupported layersorlayerswithunsupportedcontent,suchasunsupportedsymbology. Returns: Type Description Promise Whenresolved,returnstheportalitemtowhichthelayerissaved. Example: constportalItem=newPortalItem(); awaitlayer.saveAs(portalItem); updateAttachment(feature,attachmentId,attachment){Promise} Since:ArcGISAPIforJavaScript4.9 Updatesanexistingattachmentforafeature.Thisoperationisavailableonlyifthelayer's capabilities.data.supportsAttachmentissettotrue. Parameters: feature Graphic Thefeaturecontainingtheattachmenttobeupdated. attachmentId Number Idoftheattachmenttobeupdated. attachment HTMLFormElement|FormData HTMLformthatcontainsafileuploadfieldpointingtothefiletobeaddedasanattachment. Returns: Type Description Promise Whenresolved,aFeatureEditResult objectisreturned.FeatureEditResultindicateswhetherornottheeditwassuccessful.Ifsuccessful,theobjectIdoftheresultistheIdof thenewattachment.Ifunsuccessful,italsoincludesanerrornameanderrormessage. Seealso: capabilities.data.supportsAttachment when(callback,errback){Promise}inherited Since:ArcGISAPIforJavaScript4.6 when()maybeleveragedonceaninstanceoftheclassiscreated.Thismethodtakestwoinputparameters:acallbackfunctionandanerrbackfunction. Thecallbackexecuteswhentheinstanceoftheclassloads.The errbackexecutesiftheinstanceoftheclassfailstoload. Parameters: callback Function optional Thefunctiontocallwhenthepromiseresolves. errback Function optional Thefunctiontoexecutewhenthepromisefails. Returns: Type Description Promise Returnsanewpromisefortheresultofcallbackthatmaybeusedto chainadditionalfunctions. Example: //AlthoughthisexampleusesMapView,anyclassinstancethatisapromisemayusewhen()inthesameway letview=newMapView(); view.when(function(){ //Thisfunctionwillexecuteoncethepromiseisresolved },function(error){ //Thisfunctionwillexecuteifthepromiseisrejectedduetoanerror }); TypeDefinitions AttachmentEditObject AttachmentEditrepresentsanattachmentthatcanbeadded,updatedordeletedviaapplyEdits. Thisobjectcanbeeitherpre-uploadeddataorbase64encodeddata. Properties: feature Graphic|Number|String Thefeature,objectIdorglobalIdoffeatureassociated withtheattachment. attachment Object Theattachmenttobeadded,updatedordeleted. Specification: globalId String TheglobalIdoftheattachmenttobeaddedorupdated.TheseGlobalIDsmustbefromtheGlobalIDfieldcreatedbyArcGIS. FormoreinformationonArcGISgeneratedGlobalIDs,seetheGlobalIDsandAttachmentsandrelationshipclassessectionsinthe DataPreparationdocumentation. name String optional Thenameoftheattachment.ThisparametermustbesetiftheattachmenttypeisBlob. contentType String optional Thecontenttypeoftheattachment.Forexample,'image/jpeg'. SeetheArcGISRESTAPIdocumentation formoreinformationonsupportedattachmenttypes. uploadId String optional Theidofpre-loadedattachment. data Blob|File|String optional Theattachmentdata. EditedFeatureResultObject Since:ArcGISAPIforJavaScript4.20 ResultsreturnedfromtheapplyEditsmethodifthereturnServiceEditsOptionparameterissettooriginal-and-current-features.Itcontainsfeatures thatwereadded,deletedorupdatedindifferentfeaturelayersofafeatureserviceasaresultofeditingasinglefeaturethatparticipatesinacompositerelationshipin adatabase.Theresultsareorganizedbyeachlayeraffectedbytheedit. Forexample,ifafeatureisdeletedanditistheorigininacompositerelationship,theeditedfeaturesasaresultofthisdeletionarereturned. TheeditedFeaturesobjectreturnsfullfeaturesincludingnewlyaddedfeatures,theoriginalfeaturespriortodelete,theoriginalandcurrentfeaturesforupdates. Properties: layerId Number ThelayerIdofthefeaturelayerwherefeatureswereedited. editedFeatures Object Objectcontainingalleditedfeaturesbelongingtothespecifiedlayer. Specification: adds Graphic[] optional Newlyaddedfeaturesasaresultofeditingafeaturethatparticipatesinacompositerelationship. updates Object[] optional Objectcontainingoriginalandupdatedfeaturesasaresultofeditingafeaturethatparticipatesinacompositerelationship. Specification: original Graphic[] optional Originalfeaturebeforetheupdatetookplace. current Graphic[] optional Updatedfeatureasaresultofeditingafeaturethatparticipatesinacompositerelationship. deletes Graphic[] optional Deletedfeaturesasaresultofeditingafeaturethatparticipatesinacompositerelationship. spatialReference SpatialReference optional Editedfeaturesarereturnedinthespatialreferenceofthefeatureservice. EditFieldsInfoObject Since:ArcGISAPIforJavaScript4.11 Thefieldsthatrecordwhoaddsoreditsdatainthefeatureserviceandwhentheeditismade. Properties: creatorField String Thenameofthefieldthatstoresthenameoftheuserwhocreatedthefeature. creationDateField String Thenameofthefieldthatstoresthedateandtimethefeaturewascreated. editorField String Thenameofthefieldthatstoresthenameoftheuserwholasteditedthefeature. editDateField String Thenameofthefieldthatstoresthedateandtimethefeaturewaslastedited. EditingInfoObject Since:ArcGISAPIforJavaScript4.12 Specifiesinformationaboutediting. Property: lastEditDate Date Indicatesthelasttimethelayerwasedited.Thisvaluegetsupdatedeverytimethelayer'sdataiseditedorwhenanyofitspropertieschange. EditsResultObject ResultsreturnedfromtheapplyEditsmethod. Properties: addFeatureResults FeatureEditResult[] Resultofaddingfeatures. updateFeatureResults FeatureEditResult[] Resultofupdatingfeatures. deleteFeatureResults FeatureEditResult[] Resultofdeletingfeatures. addAttachmentResults FeatureEditResult[] Resultofaddingattachments. updateAttachmentResults FeatureEditResult[] Resultofupdatingattachments. deleteAttachmentResults FeatureEditResult[] Resultofdeletingattachments. editedFeatureResults EditedFeatureResult[] optional Editedfeaturesasresultofeditingafeaturethatparticipatesincompositerelationshipsinadatabase. ThisparameterisreturnedonlywhenthereturnServiceEditsOptionparameteroftheapplyEdits()methodissettooriginal-and-current-features.Thisparameterwasaddedat4.20. editMoment Number optional Thetimeeditswereappliedtothefeatureservice. ThisparameterisreturnedonlywhenthereturnEditMomentparameteroftheapplyEdits()methodissettotrue.Thisoptionwasaddedattheversion4.20. FeatureEditResultObject FeatureEditResultrepresentstheresultofadding,updatingordeletingafeatureoranattachment. Properties: objectId Number TheobjectIdofthefeatureortheattachmentIdoftheattachmentthatwasedited. globalId String TheglobalIdofthefeatureortheattachmentthatwasedited. error Object Iftheeditfailed,theeditresultincludesanerror. Specification: name String Errorname. message String Messagedescribingtheerror. EventOverview Showinheritedevents Hideinheritedevents Name Type Summary Class edits {addedFeatures:FeatureEditResult[],deletedFeatures:FeatureEditResult[],updatedFeatures:FeatureEditResult[],addedAttachments:FeatureEditResult[],deletedAttachments:FeatureEditResult[],updatedAttachments:FeatureEditResult[],editedFeatures:EditedFeatureResult} moredetails FiresafterapplyEdits()iscompletedsuccessfully. moredetails FeatureLayer layerview-create {view:View,layerView:LayerView} moredetails Firesafterthelayer'sLayerViewiscreatedandrenderedinaview. moredetails Layer layerview-create-error {view:View,error:Error} moredetails FireswhenanerroremitsduringthecreationofaLayerViewafteralayerhasbeenaddedtothemap. moredetails Layer layerview-destroy {view:View,layerView:LayerView} moredetails Firesafterthelayer'sLayerViewisdestroyedandnolongerrendersinaview. moredetails Layer refresh {dataChanged:Boolean} moredetails FiresifthelayerhastherefreshIntervalsetorwhenrefresh()methodiscalled. moredetails FeatureLayer EventDetails edits Since:ArcGISAPIforJavaScript4.12 FiresafterapplyEdits()iscompletedsuccessfully. Theeventpayloadincludesonlysuccessfuledits,notthefailededits. Properties: addedFeatures FeatureEditResult[] Anarrayofsuccessfullyaddedfeatures. deletedFeatures FeatureEditResult[] Anarrayofsuccessfullydeletedfeatures. updatedFeatures FeatureEditResult[] Anarrayofsuccessfullyupdatedfeatures. addedAttachments FeatureEditResult[] Anarrayofsuccessfullyaddedattachments. deletedAttachments FeatureEditResult[] Anarrayofsuccessfullydeletedattachments. updatedAttachments FeatureEditResult[] Anarrayofsuccessfullyupdatedattachments. editedFeatures EditedFeatureResult Editedfeaturesasresultofeditingafeaturethatparticipatesincompositerelationshipsinadatabase. ThisparameterisreturnedonlywhenthereturnServiceEditsOptionparameteroftheapplyEdits()methodissettooriginal-and-current-features.Thisparameterwasaddedat4.20. Seealso: applyEdits() Example: //ThisfunctionwillfireeachtimeapplyEdits()iscompletedsuccessfully featureLayer.on("edits",function(event){ constextractObjectId=function(result){ returnresult.objectId; }; constadds=event.addedFeatures.map(extractObjectId); console.log("addedFeatures:",adds.length,adds); constupdates=event.updatedFeatures.map(extractObjectId); console.log("updatedFeatures:",updates.length,updates); constdeletes=event.deletedFeatures.map(extractObjectId); console.log("deletedFeatures:",deletes.length,deletes); }); layerview-createinherited Firesafterthelayer'sLayerViewiscreatedandrenderedinaview. Properties: view View TheviewinwhichthelayerViewwascreated. layerView LayerView TheLayerViewrendered intheviewrepresentingthelayerinlayer. Seealso: View.whenLayerView() Example: //Thisfunctionwillfireeachtimealayerviewiscreatedforthis //particularview. layer.on("layerview-create",function(event){ //TheLayerViewforthelayerthatemittedthisevent event.layerView; }); layerview-create-errorinherited FireswhenanerroremitsduringthecreationofaLayerView afteralayerhasbeenaddedtothemap. Properties: view View Theviewthatfailedtocreatealayerviewforthelayer emittingthisevent. error Error Anerrorobjectdescribingwhythelayerviewfailedtocreate. Seealso: View.whenLayerView() Example: //Thisfunctionfireswhenanerroroccursduringthecreationofthelayer'slayerview layer.on("layerview-create-error",function(event){ console.error("LayerViewfailedtocreateforlayerwiththeid:",layer.id,"inthisview:",event.view); }); layerview-destroyinherited Firesafterthelayer'sLayerViewisdestroyedandnolongerrendersinaview. Properties: view View TheviewinwhichthelayerViewwasdestroyed. layerView LayerView ThedestroyedLayerViewrepresentingthelayer. refresh Since:ArcGISAPIforJavaScript4.21 FiresifthelayerhastherefreshIntervalsetorwhenrefresh()methodiscalled. Theeventpayloadindicatesifthelayer'sdatahaschanged. Property: dataChanged Boolean Indicatesifthelayer'sdatahaschanged. Seealso: refreshInterval refresh() Example: //listentolayer'srefresheventtofetchtheattachments //fortheupdatedfeatures. layer.on("refresh",function(event){ if(event.dataChanged){ constquery=layer.createQuery(); layer.queryObjectIds(query).then(function(objectIds){ letattachmentQuery={ objectIds:objectIds, definitionExpression:layer.definitionExpression, attachmentTypes:["image/jpeg"] }; layer.queryAttachments(attachmentQuery).then(function(attachments){ attachmentQuery.objectIds.forEach(function(objectId){ if(attachments[objectId]){ //processtheupdatedattachments letattachment=attachments[objectId]; } }); }) .catch(function(error){ console.log("attachmentqueryerror",error); }); }); } }); ConstructorsPropertiesMethodsTypedefinitionsEventsShowtableofcontentsConstructorsPropertiesMethodsTypedefinitionsEventsWasthispagehelpful?YesNoWasthispagehelpful?YesNoYourbrowserisnolongersupported.Pleaseupgradeyourbrowserforthebestexperience.Seeourbrowserdeprecationpostformoredetails.



請為這篇文章評分?