FeatureLayer | API Reference | ArcGIS API for JavaScript 4.4

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

A FeatureLayer is a single layer that can be created from a Map Service or Feature Service; ArcGIS Online or ArcGIS for Portal items; or from an array of client ... esriBasemapCameraColorconfigGraphicGroundkernelMapPopupTemplaterequestViewpointWebMapWebSceneesri/coreAccessorCollectionlangpromiseUtilsrequireUtilsurlUtilswatchUtilsworkersesri/core/accessorSupportdecoratorsesri/core/workersConnectionesri/geometryCircleExtentGeometrygeometryEnginegeometryEngineAsyncMultipointPointPolygonPolylineScreenPointSpatialReferenceesri/geometry/supportjsonUtilsnormalizeUtilswebMercatorUtilsesri/identityCredentialIdentityManagerIdentityManagerBaseOAuthInfoServerInfoesri/layersBaseDynamicLayerBaseElevationLayerBaseTileLayerCSVLayerElevationLayerFeatureLayerGeoRSSLayerGraphicsLayerGroupLayerImageryLayerIntegratedMeshLayerLayerMapImageLayerMapNotesLayerOpenStreetMapLayerPointCloudLayerSceneLayerStreamLayerTileLayerUnknownLayerUnsupportedLayerVectorTileLayerWebTileLayerWMSLayerWMTSLayeresri/layers/supportCodedValueDomainDimensionalDefinitionDomainFeatureTemplateFeatureTypeFieldImageParametersInheritedDomainLabelClassLODMapImageMosaicRulePixelBlockRangeDomainRasterFunctionSublayerTileInfoTileMatrixSetWMSSublayerWMTSStyleWMTSSublayeresri/portalPortalPortalFolderPortalGroupPortalItemPortalQueryParamsPortalQueryResultPortalRatingPortalUseresri/renderersClassBreaksRendererPointCloudClassBreaksRendererPointCloudRendererPointCloudRGBRendererPointCloudStretchRendererPointCloudUniqueValueRendererRendererSimpleRendererUniqueValueRendereresri/renderers/smartMapping/creatorscolorlocationsizetypeunivariateColorSizeesri/renderers/smartMapping/statisticsclassBreakshistogramsummaryStatisticsuniqueValuesesri/renderers/smartMapping/symbologycolorlocationsizetypeesri/renderers/supportjsonUtilsesri/supportActionesri/symbolsExtrudeSymbol3DLayerFillSymbolFillSymbol3DLayerFontIconSymbol3DLayerLabelSymbol3DLineSymbolLineSymbol3DLineSymbol3DLayerMarkerSymbolMeshSymbol3DObjectSymbol3DLayerPathSymbol3DLayerPictureFillSymbolPictureMarkerSymbolPointSymbol3DPolygonSymbol3DSimpleFillSymbolSimpleLineSymbolSimpleMarkerSymbolSymbolSymbol3DSymbol3DLayerTextSymbolTextSymbol3DLayerWebStyleSymbolesri/symbols/calloutsCallout3DLineCallout3Desri/symbols/supportjsonUtilsesri/tasksClosestFacilityTaskFindTaskGeometryServiceGeoprocessorIdentifyTaskImageServiceIdentifyTaskLocatorPrintTaskQueryTaskRouteTaskServiceAreaTaskTaskesri/tasks/supportAddressCandidateAreasAndLengthsParametersBufferParametersClosestFacilityParametersClosestFacilitySolveResultDataFileDataLayerDateDensifyParametersDirectionsFeatureSetDistanceParametersFeatureSetFindParametersFindResultGeneralizeParametersGPMessageIdentifyParametersIdentifyResultImageServiceIdentifyParametersImageServiceIdentifyResultJobInfoLegendLayerLengthsParametersLinearUnitNAMessageOffsetParametersParameterValuePrintParametersPrintTemplateProjectParametersQueryRasterDataRelationParametersRelationshipQueryRouteParametersRouteResultServiceAreaParametersServiceAreaSolveResultStatisticDefinitionTrimExtendParametersesri/tasks/workflowConfigurationTaskJobTaskNotificationTaskReportTaskTokenTaskWorkflowTaskesri/viewsMapViewSceneViewViewViewAnimationesri/views/3dexternalRenderersesri/views/layersCSVLayerViewFeatureLayerViewGraphicsLayerViewImageryLayerViewLayerViewSceneLayerViewStreamLayerViewesri/views/uiDefaultUIUIesri/webmapInitialViewPropertiesesri/websceneEnvironmentInitialViewPropertiesLightingPresentationSlideesri/widgetsAttributionBasemapGalleryBasemapToggleColorSliderCompassExpandHomeLayerListLegendLocateNavigationTogglePopupPrintScaleBarSearchSizeSliderTrackUnivariateColorSizeSliderWidgetZoomesri/widgets/supportwidgetBacktoTopConstructorsPropertiesMethodsTypedefinitionsEventsBasemapCameraColorconfigGraphicGroundkernelMapPopupTemplaterequestViewpointWebMapWebSceneAccessorCollectionlangpromiseUtilsrequireUtilsurlUtilswatchUtilsworkersdecoratorsConnectionCircleExtentGeometrygeometryEnginegeometryEngineAsyncMultipointPointPolygonPolylineScreenPointSpatialReferencejsonUtilsnormalizeUtilswebMercatorUtilsCredentialIdentityManagerIdentityManagerBaseOAuthInfoServerInfoBaseDynamicLayerBaseElevationLayerBaseTileLayerCSVLayerElevationLayerFeatureLayerGeoRSSLayerGraphicsLayerGroupLayerImageryLayerIntegratedMeshLayerLayerMapImageLayerMapNotesLayerOpenStreetMapLayerPointCloudLayerSceneLayerStreamLayerTileLayerUnknownLayerUnsupportedLayerVectorTileLayerWebTileLayerWMSLayerWMTSLayerCodedValueDomainDimensionalDefinitionDomainFeatureTemplateFeatureTypeFieldImageParametersInheritedDomainLabelClassLODMapImageMosaicRulePixelBlockRangeDomainRasterFunctionSublayerTileInfoTileMatrixSetWMSSublayerWMTSStyleWMTSSublayerPortalPortalFolderPortalGroupPortalItemPortalQueryParamsPortalQueryResultPortalRatingPortalUserClassBreaksRendererPointCloudClassBreaksRendererPointCloudRendererPointCloudRGBRendererPointCloudStretchRendererPointCloudUniqueValueRendererRendererSimpleRendererUniqueValueRenderercolorlocationsizetypeunivariateColorSizeclassBreakshistogramsummaryStatisticsuniqueValuescolorlocationsizetypejsonUtilsActionExtrudeSymbol3DLayerFillSymbolFillSymbol3DLayerFontIconSymbol3DLayerLabelSymbol3DLineSymbolLineSymbol3DLineSymbol3DLayerMarkerSymbolMeshSymbol3DObjectSymbol3DLayerPathSymbol3DLayerPictureFillSymbolPictureMarkerSymbolPointSymbol3DPolygonSymbol3DSimpleFillSymbolSimpleLineSymbolSimpleMarkerSymbolSymbolSymbol3DSymbol3DLayerTextSymbolTextSymbol3DLayerWebStyleSymbolCallout3DLineCallout3DjsonUtilsClosestFacilityTaskFindTaskGeometryServiceGeoprocessorIdentifyTaskImageServiceIdentifyTaskLocatorPrintTaskQueryTaskRouteTaskServiceAreaTaskTaskAddressCandidateAreasAndLengthsParametersBufferParametersClosestFacilityParametersClosestFacilitySolveResultDataFileDataLayerDateDensifyParametersDirectionsFeatureSetDistanceParametersFeatureSetFindParametersFindResultGeneralizeParametersGPMessageIdentifyParametersIdentifyResultImageServiceIdentifyParametersImageServiceIdentifyResultJobInfoLegendLayerLengthsParametersLinearUnitNAMessageOffsetParametersParameterValuePrintParametersPrintTemplateProjectParametersQueryRasterDataRelationParametersRelationshipQueryRouteParametersRouteResultServiceAreaParametersServiceAreaSolveResultStatisticDefinitionTrimExtendParametersConfigurationTaskJobTaskNotificationTaskReportTaskTokenTaskWorkflowTaskMapViewSceneViewViewViewAnimationexternalRenderersCSVLayerViewFeatureLayerViewGraphicsLayerViewImageryLayerViewLayerViewSceneLayerViewStreamLayerViewDefaultUIUIInitialViewPropertiesEnvironmentInitialViewPropertiesLightingPresentationSlideAttributionBasemapGalleryBasemapToggleColorSliderCompassExpandHomeLayerListLegendLocateNavigationTogglePopupPrintScaleBarSearchSizeSliderTrackUnivariateColorSizeSliderWidgetZoomwidgetOverviewCreatingaFeatureLayerQueryingDataVisualizationOverviewAFeatureLayerisasinglelayerthatcanbecreatedfromaMapServiceorFeatureService;ArcGISOnlineorArcGISforPortalitems;orfromanarrayofclient-sidegraphics.Itiscomposedofdiscretefeatures,eachofwhichhasaGeometrythatallowsittoberenderedineithera2DMapViewor3DSceneViewasagraphicwithspatialcontext.Featuresalsocontaindataattributesthatprovideadditionalinformationaboutthereal-worldfeatureitrepresents;attributesmaybeviewedinpopupwindowsandusedforrenderingthelayer.FeatureLayersmaybequeried,analyzed,andrenderedtovisualizedatainaspatialcontext.KnownLimitationsSomefeaturesmaynotbevisibleintheviewbecauseofpresentlimitationsofthefetchstrategyintheAPI.Thefetchstrategywillcontinuallyimproveasneededinfutureversions.AninstanceofthisclassisalsoaPromise.Thisallowsyoutoexecutecodeoncethepromiseresolves,orwhenthelayerfinishesloadingitsresources.Seethen()foradditionaldetails.CreatingaFeatureLayerFeatureLayersmaybecreatedinoneofthreeways:fromaserviceURL,anArcGISPortalitemID,orfromanarrayofclient-sidegraphics.ReferenceaserviceURLTocreateaFeatureLayerinstancefromaservice,youmustsettheurlpropertytotheRESTendpointofalayerineitheraFeatureServiceoraMapService.Foralayertobevisibleinaview,itmustbeaddedtotheMapreferencedbytheview.SeeMap.add()forinformationaboutaddinglayerstoamap.require(["esri/layers/FeatureLayer"],function(FeatureLayer){ //pointstothestateslayerinaservicestoringU.S.censusdata varfl=newFeatureLayer({ url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3" }); map.add(fl);//addsthelayertothemap }); Iftheserviceisrequestedfromadifferentdomain,aCORSenabledserveroraproxyisrequired.IfCORSisenabledontheserveraddtheservicedomaintoesriConfig.request.corsEnabledServers.Alternatively,ifCORScannotbeenabledonArcGISServeryoucansetupaproxyonyourwebserverandthenaddittotheproxyruleslistinesriConfigusingaddProxyRule().ReferenceanArcGISPortalItemIDYoucanalsocreateaFeatureLayerfromitsIDifitexistsasaniteminArcGISOnlineorArcGISforPortal.Forexample,thefollowingsnippetshowshowtoaddanewFeatureLayerinstancetoamapusingtheportalItemproperty.//pointstoahostedFeatureLayerinArcGISOnline varfl=newFeatureLayer({ portalItem:{//autocastsasesri/portal/PortalItem id:"8444e275037549c1acab02d2626daaee" } }); map.add(fl);//addsthelayertothemap Addanarrayofclient-slidegraphicsClient-sidegraphicsmayalsobeusedtocreateaFeatureLayer.SincetheFeatureLayerrequiresaschema,severalpropertiesneedtobesetwhencreatingalayerfromanarrayofgraphics.Thegeometrytypeofthefeaturesmustbeindicated(sinceonlyonegeometrytypeisallowedperlayer)usingthegeometryTypepropertyalongwithavalidspatialreference.AnObjectIDfieldmustbeindicatedalongwithanarrayoffieldobjects,providingtheschemaofeachfield.Oncethosepropertiesarespecified,thearrayofgraphicsmustbesettothesourceproperty.ThereisnolimittothenumberofgraphicsthatmaybeaddedtoaFeatureLayerviasource.varlyr=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", geometryType:"point", spatialReference:{wkid:4326}, source:graphics,//anarrayofgraphicswithgeometryandattributes //popupTemplateandsymbolarenotrequiredineachgraphic //sincethosearehandledwiththepopupTemplateand //rendererpropertiesofthelayer popupTemplate:pTemplate, renderer:uvRenderer//UniqueValueRendererbasedon`type`attribute }); map.add(lyr); QueryingFeatureswithinaFeatureLayerarerenderedasgraphicsinsideaLayerView.ThereforethegraphicsvisibleinaviewareaccessedviatheLayerView,nottheFeatureLayer.Toaccessfeaturesvisibleintheview,usethequerymethodsintheFeatureLayerView.//returnsallthegraphicsfromthelayerview view.whenLayerView(lyr).then(function(lyrView){ lyrView.watch("updating",function(val){ if(!val){//waitforthelayerviewtofinishupdating lyrView.queryFeatures().then(function(results){ console.log(results);//printsalltheclient-sidegraphicstotheconsole }); } }); }); WhenaccessingfeaturesfromaqueryontheFeatureLayerView,notethatfeaturesarereturnedastheyaredisplayedintheview,includinganygeneralizationthatmayhavebeenappliedtothefeaturestoenhanceperformance.Toobtainfeaturegeometriesatfullresolution,usethequeryFeatures()methodontheFeatureLayer.ThequerymethodsmethodsintheFeatureLayerclassqueryfeaturesdirectlyfromtheservice.Forexample,thefollowingsnippetreturnsallfeaturesfromtheservice,notjustthefeaturesdrawnintheFeatureLayerView.//Queriesforallthefeaturesintheservice(notthegraphicsintheview) layer.queryFeatures().then(function(results){ //printsanarrayofallthefeaturesintheservicetotheconsole console.log(results.features); }); ForinformationregardinghowtocreateaLayerViewforaparticularlayer,seeView.whenLayerView().DataVisualizationFeaturesinaFeatureLayerarevisualizedbysettingaRenderertotherendererpropertyofthelayer.FeaturesmaybevisualizedwiththesamesymbolusingSimpleRenderer,bytypewithUniqueValueRenderer,withclassbreaksusingClassBreaksRenderer,orwithcontinuouscolor,size,oropacityschemesusingvisualvariablesinanyoftherenderers.SeethedocumentationforRendererandtheCreatingvisualizationsmanuallyguideformoreinformationaboutthevariousvisualizationoptionsforFeatureLayers.Seealso:Sample-AddFeatureLayertoyourMapSample-CreateaFeatureLayerwithGeoJSONdataSample-QueryfeaturesfromaFeatureLayerMapConstructorsnewFeatureLayer(properties)Parameter:propertiesObjectoptionalSeethepropertiesforalistofallthepropertiesthatmaybepassedintotheconstructor.Example://Typicalusage varlayer=newFeatureLayer({ //URLtotheservice url:"https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0" });PropertyOverviewAnypropertiescanbeset,retrievedorlistenedto.SeetheWorkingwithPropertiestopic.NameTypeSummarycapabilitiesObjectIndicatesthelayer'ssupportedcapabilities.moredetailsmoredetailscopyrightStringThecopyrighttextasdefinedbythemapservice.moredetailsmoredetailsdeclaredClassStringThenameoftheclass.moredetailsmoredetailsdefinitionExpressionStringTheSQLwhereclauseusedtofilterfeaturesontheclient.moredetailsmoredetailsdisplayFieldStringThenameofthelayer'sprimarydisplayfield.moredetailsmoredetailselevationInfoObjectSpecifieshowgraphicsareplacedontheverticalaxis(z).moredetailsmoredetailsfeatureReductionObjectConfiguresthemethodfordeclutteringoverlappingfeaturesintheview.moredetailsmoredetailsfieldsField[]Anarrayoffieldsinthelayer.moredetailsmoredetailsfullExtentExtentThefullextentofthelayer.moredetailsmoredetailsgdbVersionStringTheversionofthegeodatabaseofthefeatureservicedata.moredetailsmoredetailsgeometryTypeStringThegeometrytypeoffeaturesinthelayer.moredetailsmoredetailshasAttachmentsBooleanValueistrueifattachmentsareenabledonthefeaturelayer.moredetailsmoredetailshasMBooleanIndicatesifthefeaturesinthelayerhaveMvalues.moredetailsmoredetailshasZBooleanIndicatesifthefeaturesinthelayerhaveZvalues.moredetailsmoredetailsidStringTheuniqueIDassignedtothelayer.moredetailsmoredetailslabelingInfoLabelClass[]Thelabeldefinitionforthislayer,specifiedasanarrayofLabelClass.moredetailsmoredetailslabelsVisibleBooleanIndicateswhethertodisplaylabelsforthislayer.moredetailsmoredetailslayerIdNumberThelayerID,orlayerindex,ofaFeatureServicelayer.moredetailsmoredetailslegendEnabledBooleanIndicateswhetherthelayerwillbeincludedinthelegend.moredetailsmoredetailslistModeStringIndicateshowthelayershoulddisplayintheLayerListwidget.moredetailsmoredetailsloadedBooleanIndicateswhetherthelayer'sresourceshaveloaded.moredetailsmoredetailsloadErrorErrorTheErrorobjectreturnedifanerroroccurredwhileloading.moredetailsmoredetailsloadStatusStringRepresentsthestatusofaloadoperation.moredetailsmoredetailsloadWarningsObject[]Alistofwarningswhichoccurredwhileloading.moredetailsmoredetailsmaxScaleNumberThemaximumscaleatwhichthelayerisvisibleintheview.moredetailsmoredetailsminScaleNumberTheminimumscaleatwhichthelayerisvisibleintheview.moredetailsmoredetailsobjectIdFieldStringThenameofoneoftheprovidedfieldsforeachgraphiccontainingauniquevalueoridentifierforthatgraphic.moredetailsmoredetailsopacityNumberTheopacityofthelayer.moredetailsmoredetailsoutFieldsString[]AnarrayoffieldnamesfromtheservicetoincludeintheFeatureLayer.moredetailsmoredetailspopupEnabledBooleanIndicateswhethertodisplaypopupswhenfeaturesinthelayerareclicked.moredetailsmoredetailspopupTemplatePopupTemplateThepopuptemplateforthelayer.moredetailsmoredetailsportalItemPortalItemTheportalitemfromwhichthelayerisloaded.moredetailsmoredetailsrendererRendererTherendererassignedtothelayer.moredetailsmoredetailsreturnMBooleanWhentrue,indicatesthatMvalueswillbereturned.moredetailsmoredetailsreturnZBooleanWhentrue,indicatesthatZvalueswillbereturned.moredetailsmoredetailsscreenSizePerspectiveEnabledBooleanApplyperspectivescalingtoscreen-sizepointsymbolsinaSceneView.moredetailsmoredetailssourceCollectionAcollectionofGraphicobjectsusedtocreateaFeatureLayer.moredetailsmoredetailsspatialReferenceSpatialReferenceThespatialreferenceofthelayer.moredetailsmoredetailstemplatesFeatureTemplate[]Anarrayoffeaturetemplatesdefinedinthefeaturelayer.moredetailsmoredetailstitleStringThetitleofthelayerusedtoidentifyitinplacessuchastheLegendandLayerListwidgets.moredetailsmoredetailstokenStringTokengeneratedbythetokenserviceusingthespecifieduserIdandpassword.moredetailsmoredetailstypeStringForFeatureLayerthetypeisfeature.moredetailsmoredetailstypeIdFieldStringThenameofthefieldholdingthetypeIDorsubtypesforthefeatures.moredetailsmoredetailstypesFeatureType[]AnarrayofsubtypesdefinedinthefeatureserviceexposedbyArcGISRESTAPI.moredetailsmoredetailsurlStringTheURLoftheRESTendpointofthelayerorservice.moredetailsmoredetailsversionNumberTheversionofArcGISServerinwhichthelayerispublished.moredetailsmoredetailsvisibleBooleanIndicatesifthelayerisvisibleintheView.moredetailsmoredetailsPropertyDetailscapabilitiesObjectreadonlyIndicatesthelayer'ssupportedcapabilities.Properties:dataObjectIndicatesdatacapabilitiesthatcanbeperformedonfeaturesinthelayer.Specification:supportsAttachmentBooleanIndicatesiftheattachmentisenabledonthelayer.supportsMBooleanIndicatesifthefeaturesinthelayersupportMvalues.RequiresArcGISServerservice10.1orgreater.supportsZBooleanIndicatesifthefeaturesinthelayersupportZvalues.RequiresArcGISServerservice10.1orgreater.SeeelevationInfofordetailsregardingplacementandrenderingofgraphicswithz-valuesin3DSceneViews.editingObjectIndicateseditingcapabilitiesthatcanbeperformedonthefeaturesinthelayer.Specification:supportsDeleteByAnonymousBooleanIndicatesifanonymoususerscandeletefeaturescreatedbyothers.supportsDeleteByOthersBooleanIndicatesifloggedinuserscandeletefeaturescreatedbyothers.supportsGeometryUpdateBooleanIndicatesifthegeometryofthefeaturesinthelayercanbeedited.supportsGlobalIdBooleanIndicatesiftheglobalidvaluesprovidedbytheclientareusedinapplyEdits.supportsRollbackOnFailureBooleanIndicatesiftherollbackOnFailureparametercanbesettotrueorfalsewhenrunningthesynchronizeReplicaoperation.supportsUpdateByAnonymousBooleanIndicatesifanonymoususerscanupdatefeaturescreatedbyothers.supportsUpdateByOthersBooleanIndicatesifloggedinuserscanupdatefeaturescreatedbyothers.supportsUpdateWithoutMBooleanIndicatesifm-valuesmustbeprovidedwhenupdatingfeatures.supportsUploadWithItemIdBooleanIndicatesifthelayersupportsuploadingattachmentsbyUploadId.operationsObjectIndicatesoperationsthatcanbeperformedonfeaturesinthelayer.Specification:supportsAddBooleanIndicatesifnewfeaturescanbeaddedtothelayer.supportsDeleteBooleanIndicatesiffeaturescanbedeletedfromthelayer.supportsUpdateBooleanIndicatesiffeaturesinthelayercanbeupdated.supportsEditingBooleanIndicatesiffeaturesinthelayercanbeedited.UsesupportsAdd,supportsUpdateandsupportsDeletetodeterminewhicheditingoperationsaresupported.supportsCalculateBooleanIndicatesifvaluesofoneormorefieldvaluesinthelayercanbeupdated.SeetheCalculateRESToperationdocumentformoreinformation.supportsQueryBooleanIndicatesiffeaturesinthelayercanbequeried.supportsValidateSqlBooleanIndicatesifthelayersupportsaSQL-92expressionorwhereclause.ThisoperationisonlysupportedinArcGISOnlinehostedfeatureservices.queryObjectIndicatesqueryoperationsthatcanbeperformedonfeaturesinthelayer.Specification:supportsCentroidBooleanIndicatesifthegeometrycentroidassociatedwitheachpolygonfeaturecanbereturned.ThisoperationisonlysupportedinArcGISOnlinehostedfeatureservices.supportsDistanceBooleanIndicatesifthelayer'squeryoperationsupportsabufferdistanceforinputgeometries.supportsDistinctBooleanIndicatesifthelayersupportsqueriesfordistinctvaluesbasedonfieldsspecifiedintheoutFields.supportsExtentBooleanIndicatesifthelayer'squeryresponseincludestheextentoffeatures.At10.3,thisoptionisonlyavailableforhostedfeatureservices.At10.3.1,itisavailableforhostedandnon-hostedfeatureservices.supportsGeometryPropertiesBooleanIndicatesifthelayer'squeryresponsecontainsgeometryattributes,includingshapeareaandlengthattributes.ThisoperationisonlysupportedinArcGISOnlinehostedfeatureservices.supportsOrderByBooleanIndicatesiffeaturesreturnedinthequeryresponsecanbeorderedbyoneormorefields.RequiresanArcGISServerservice10.3orgreater.supportsPaginationBooleanIndicatesifthequeryresponsesupportspagination.RequiresanArcGISServerservice10.3orgreater.supportsQuantizationBooleanIndicatesifthequeryoperationsupportstheprojectionofgeometriesontoavirtualgrid.RequiresanArcGISServerservice10.3orgreater.supportsResultTypeBooleanIndicatesifthenumberoffeaturesreturnedbythequeryoperationcanbecontrolled.supportsSqlExpressionBooleanIndicatesifthequeryoperationsupportsSQLexpressions.supportsStandardizedQueriesOnlyBooleanIndicatesifthequeryoperationsupportsusingstandardizedqueries.Learnmoreaboutstandardizedquerieshere.supportsStatisticsBooleanIndicatesifthelayersupportsfield-basedstatisticalfunctions.RequiresArcGISServerservice10.1orgreater.queryRelatedObjectIndicatesifthelayer'squeryoperationsupportsqueryingfeaturesorrecordsrelatedtofeaturesinthelayer.Specification:supportsCountBooleanIndicatesifthelayer'squeryresponseincludesthenumberoffeaturesorrecordsrelatedtofeaturesinthelayer.supportsOrderByBooleanIndicatesiftherelatedfeaturesorrecordsreturnedinthequeryresponsecanbeorderedbyoneormorefields.RequiresArcGISServerservice10.3orgreater.supportsPaginationBooleanIndicatesifthequeryresponsesupportspaginationforrelatedfeaturesorrecords.RequiresArcGISServerservice10.3orgreater.Example://Oncethelayerloads,checkifthe //supportsAddoperationsisenabledonthelayer featureLayer.then(function(){ if(featureLayer.capabilities.operations.supportsAdd){ //ifnewfeaturescanbecreatedinthelayer //setuptheUIforediting setupEditing(); } });copyrightStringThecopyrighttextasdefinedbythemapservice.declaredClassStringreadonlyThenameoftheclass.Thedeclaredclassnameisformattedasesri.folder.className.definitionExpressionStringTheSQLwhereclauseusedtofilterfeaturesontheclient.OnlythefeaturesthatsatisfythedefinitionexpressionaredisplayedintheView.Settingadefinitionexpressionisusefulwhenthedatasetislargeandyoudon'twanttobringallfeaturestotheclientforanalysis.Definitionexpressionsmaybesetwhenalayerisconstructedpriortoitloadinginthevieworafterithasbeenaddedtothemap.Ifthedefinitionexpressionissetafterthelayerhasbeenaddedtothemap,theviewwillautomaticallyrefreshitselftodisplaythefeaturesthatsatisfythenewdefinitionexpression.Examples://SetdefinitionexpressioninconstructortoonlydisplaytreeswithscientificnameUlmuspumila varlayer=newFeatureLayer({ url:"https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0" definitionExpression:"Sci_Name='Ulmuspumila'" });//Setthedefinitionexpressiondirectlyonlayerinstancetoonlydisplaytreestallerthan50ft layer.definitionExpression="HEIGHT>50";displayFieldStringSince:ArcGISAPIforJavaScript4.4Thenameofthelayer'sprimarydisplayfield.Thevalueofthispropertymatchesthenameofoneofthefieldsofthelayer.elevationInfoObjectSpecifieshowgraphicsareplacedontheverticalaxis(z).ThispropertymayonlybeusedinaSceneView.SeetheElevationInfosampleforanexampleofhowthispropertymaybeused.Properties:modeStringDefineshowthegraphicisplacedwithrespecttotheterrainsurface.returnZmustbesettotrueifz-valuesofthefeaturesshouldbeconsideredfortheelevationmode.Ifthegeometryconsistsofmultiplepoints(e.g.linesorpolygons),theelevationisevaluatedseparatelyforeachpoint.Seethetablebelowforalistofpossiblevalues.ModeDescriptionon-the-groundGraphicsaredrapedontheterrainsurface.ThisisthedefaultvalueforfeatureswithPolylineorPolygongeometriesandfeatureswithPointgeometriesrenderedwithObjectSymbol3DLayers.relative-to-groundThegraphicisplacedatanelevationrelativetotheterrainsurface.Thegraphic'selevationisdeterminedbysumminguptheterrainelevation,theoffsetvalueandthegeometry'sz-value(ifpresent).ThisisthedefaultvalueforPointgeometriesrenderedwithIconSymbol3DLayers.absolute-heightGraphicsareplacedatanabsoluteheightabovesealevel.Thisheightisdeterminedbysumminguptheoffsetvalueandthegeometry'sz-value(ifpresent).Itdoesn'ttaketheelevationoftheterrainintoaccount.ThisisthedefaultvalueoffeatureswithanygeometrytypewherehasZistrue.relative-to-sceneGraphicsarealignedtobuildingsandotherobjectspartof3DObjectSceneLayerorIntegratedMeshLayer,dependingonwhichhashigherelevation.Ifthegraphicisnotdirectlyaboveabuildingoranyotherfeature,itisalignedtotheterrainsurfaceelevation.Ifpresent,z-valueswillbeignored.offsetNumberoptionalAnelevationoffsetinmeters,whichisaddedtotheverticalpositionofthegraphic.Whenmode="on-the-ground",thispropertyhasnoeffect.featureReductionObjectSince:ArcGISAPIforJavaScript4.4Configuresthemethodfordeclutteringoverlappingfeaturesintheview.Ifthispropertyisnotset(orsettonull),everyfeatureisdrawnindividually.Currentlythispropertyisonlysupportedin3DSceneViewsforpointfeatureswithnon-drapedIconsorTextsymbollayers.Property:typeStringTypeofthedeclutteringmethod.Theonlysupportedtypeatthemomentis"selection".Inthismethod,someoftheoverlappingfeaturesarehiddensuchthatnoneoftheremainingfeaturesintersectonscreen.Labeldeconflictionalsorespectsthisoptionandhideslabelsthatwouldoverlapwiththefeaturesofthislayer.Seealso:Sample:PointstylesforcitiesExample:layer.featureReduction={ type:"selection" };fieldsField[]autocastAnarrayoffieldsinthelayer.Eachfieldrepresentsanattributethatmaycontainavalueforeachfeatureinthelayer.Forexample,afieldnamedPOP_2015,storesinformationabouttotalpopulationasanumericvalueforeachfeature;thisvaluerepresentsthetotalnumberofpeoplelivingwithinthegeographicboundsofthefeature.ThispropertymustbesetintheconstructorwhencreatingaFeatureLayerfromclient-sidegraphics.TocreateFeatureLayersfromclient-sidegraphicsyoumustalsosetthesource,objectIdField,spatialReference,andgeometryTypeproperties.Seealso:sourceobjectIdFieldExample://defineeachfield'sschema varfields=[ newField({ name:"ObjectID", alias:"ObjectID", type:"oid" }),newField({ name:"description", alias:"Description", type:"string" }),newField({ name:"title", alias:"Title", type:"string" }) ]; //Seethesamplesnippetforthesourceproperty varlayer=newFeatureLayer({ source:features, fields:fields, objectIdField:"ObjectID",//fieldnameoftheObjectIDs geometryType:"point" });fullExtentExtentautocastThefullextentofthelayer.Bydefault,thisisworldwide.Thispropertymaybeusedtosettheextentoftheviewtomatchalayer'sextentsothatitsfeaturesappeartofilltheview.Seethesamplesnippetbelow.Example://Oncethelayerloads,settheview'sextenttothelayer'sfullextent layer.then(function(){ view.extent=layer.fullExtent; });gdbVersionStringTheversionofthegeodatabaseofthefeatureservicedata.ReadtheOverviewofversioningtopicformoredetailsaboutthiscapability.geometryTypeStringThegeometrytypeoffeaturesinthelayer.Allfeaturesmustbeofthesametype.Thispropertyisread-onlywhenthelayeriscreatedfromaurl.However,whencreatingaFeatureLayerfromclient-sidegraphics,thispropetymustbespecifiedinthelayer'sconstructoralongwiththesource,spatialReference,fields,andobjectIdFieldproperties.PossibleValues:point|mulitpoint|polyline|polygonhasAttachmentsBooleanreadonlyValueistrueifattachmentsareenabledonthefeaturelayer.DefaultValue:falsehasMBooleanreadonlyIndicatesifthefeaturesinthelayerhaveMvalues.DefaultValue:falsehasZBooleanreadonlyIndicatesifthefeaturesinthelayerhaveZvalues.SeeelevationInfofordetailsregardingplacementandrenderingofgraphicswithz-valuesin3DSceneViews.DefaultValue:falseidStringTheuniqueIDassignedtothelayer.Ifnotsetbythedeveloper,itisautomaticallygeneratedwhenthelayerisloaded.labelingInfoLabelClass[]Thelabeldefinitionforthislayer,specifiedasanarrayofLabelClass.Usethispropertytospecifylabelingpropertiesforthelayersuchaslabelexpression,placement,andsize.Forlabelstodisplayintheview,thelabelsVisiblepropertyofthislayermustbesettotrue.KnownLimitationsThereisnosupportforlabelingin2D.Labelingisonlysupportedin3DSceneViews.Seealso:labelsVisibleSample:Flatvs.volumetric3DsymbollayersExample:varstatesLabelClass=newLabelClass({ labelExpressionInfo:{value:"{NAME}"}, symbol:newTextSymbol({ color:"black", haloSize:1, haloColor:"white" }) }); featureLayer.labelsVisible=true; featureLayer.labelingInfo=[statesLabelClass];labelsVisibleBooleanIndicateswhethertodisplaylabelsforthislayer.Iftrue,labelswillappearasdefinedinthelabelingInfoproperty.KnownLimitationsThereisnosupportforlabelingin2D.Labelingisonlysupportedin3DSceneViews.DefaultValue:falseSeealso:labelingInfoSample:Flatvs.volumetric3DsymbollayerslayerIdNumberThelayerID,orlayerindex,ofaFeatureServicelayer.ThisisparticularlyusefulwhenloadingasingleFeatureLayerwiththeportalItempropertyfromaservicecontainingmultiplelayers.Youcanspecifythisvalueinoneoftwoscenarios:WhenloadingthelayerviatheportalItemproperty.WhenpointingthelayerurldirectlytotheFeatureService.IfalayerIdisnotspecifiedineitheroftheabovescenarios,thenthefirstlayerintheservice(layerId=0)isselected.Examples://loadsthethirdlayerinthegivenPortalItem varlyr=newFeatureLayer({ portalItem:{ id:"8d26f04f31f642b6828b7023b84c2188" }, layerId:2 });//Ifnotspecified,thefirstlayer(layerId:0)willbereturned varlyr=newFeatureLayer({ portalItem:{ id:"8d26f04f31f642b6828b7023b84c2188" } });//CanalsobeusedifURLpointstoserviceandnotlayer varlyr=newFeatureLayer({ //Noticethattheurldoesn'tendwith/2 url:"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer", layerId:2 });//Thiscodereturnsthesamelayerastheprevioussnippet varlyr=newFeatureLayer({ //ThelayeridisspecifiedintheURL url:"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer/2", });legendEnabledBooleanIndicateswhetherthelayerwillbeincludedinthelegend.DefaultValue:truelistModeStringIndicateshowthelayershoulddisplayintheLayerListwidget.Theknownvaluesarelistedbelow.ValueDescriptionshowThelayerisvisibleinthetableofcontents.hideThelayerishiddeninthetableofcontents.hide-childrenIfthelayerisaGroupLayer,hidethechildrenlayersfromthetableofcontents.DefaultValue:showloadedBooleanreadonlyIndicateswhetherthelayer'sresourceshaveloaded.Whentrue,allthepropertiesoftheobjectcanbeaccessed.DefaultValue:falseloadErrorErrorreadonlyTheErrorobjectreturnedifanerroroccurredwhileloading.DefaultValue:nullloadStatusStringreadonlyRepresentsthestatusofaloadoperation.ValueDescriptionnot-loadedTheobject'sresourceshavenotloaded.loadingTheobject'sresourcesarecurrentlyloading.loadedTheobject'sresourceshaveloadedwithouterrors.failedTheobject'sresourcesfailedtoload.SeeloadErrorformoredetails.DefaultValue:not-loadedloadWarningsObject[]readonlyAlistofwarningswhichoccurredwhileloading.maxScaleNumberThemaximumscaleatwhichthelayerisvisibleintheview.Ifthemapiszoomedinbeyondthisscale,thelayerwillnotbevisible.Avalueof0meansthelayerdoesnothaveamaximumscale.DefaultValue:0Examples://Thelayerwillnotbevisiblewhenthe //viewiszoomedbeyondascaleof1:1,000 layer.maxScale=1000;//Thelayer'svisibilityisnotrestrictedtoamaximumscale. layer.maxScale=0;minScaleNumberTheminimumscaleatwhichthelayerisvisibleintheview.Ifthemapiszoomedoutbeyondthisscale,thelayerwillnotbevisible.Avalueof0meansthelayerdoesnothaveaminimumscale.DefaultValue:0Examples://Thelayerwillnotbevisiblewhentheview //iszoomedbeyondascaleof1:3,000,000 layer.minScale=3000000;//Thelayer'svisibilityisnotrestrictedtoaminimumscale. layer.minScale=0;objectIdFieldStringThenameofoneoftheprovidedfieldsforeachgraphiccontainingauniquevalueoridentifierforthatgraphic.ThisisrequiredwhenconstructingaFeatureLayerfromacollectionofclient-sidegraphics.WhencreatingaFeatureLayerfromclient-sidegraphics,thesource,fields,spatialReference,andgeometryTypepropertiesmustalsobeset.Seealso:fieldsExample://Seethesamplesnippetforthesourceandfieldsproperties varlayer=newFeatureLayer({ source:features, fields:fields, objectIdField:"ObjectID",//fieldnameoftheObjectIDs geometryType:"point" });opacityNumberTheopacityofthelayer.Thisvaluecanrangebetween1and0,where0is100percenttransparentand1iscompletelyopaque.DefaultValue:1Example://Makesthelayer50%transparent layer.opacity=0.5;outFieldsString[]AnarrayoffieldnamesfromtheservicetoincludeintheFeatureLayer.Ifnotspecified,thelayerwillonlyreturntheOBJECTIDfield.Tofetchthevaluesfromallfieldsinthelayer,use["*"].Thisisparticularlyusefulwheneditingfeatures.Examples://Includesallfieldsfromtheserviceinthelayer fl.outFields=["*"];//Includesonlythespecifiedfieldsfromtheserviceinthelayer fl.outFields=["NAME","POP_2010","FIPS","AREA"];popupEnabledBooleanIndicateswhethertodisplaypopupswhenfeaturesinthelayerareclicked.DefaultValue:truepopupTemplatePopupTemplateautocastThepopuptemplateforthelayer.Whensetonthelayer,thepopupTemplateallowsuserstoaccessattributesanddisplaytheirvaluesintheview'spopupwhenafeatureisselectedusingtextand/orcharts.SeethePopupTemplatesampleforanexampleofhowPopupTemplateinteractswithaFeatureLayer.portalItemPortalItemTheportalitemfromwhichthelayerisloaded.IftheportalitemreferencesaFeatureServiceorSceneService,thenyoucanspecifyasinglelayertotoloadwiththelayerIdproperty.Examples://whilethisexampleusesFeatureLayer,thissamepatterncanbe //usedforotherlayersthatmaybeloadedfromportalItemids varlyr=newFeatureLayer({ portalItem:{//autocastsasnewPortalItem() id:"caa9bd9da1f4487cb4989824053bb847" }//thefirstlayerintheserviceisreturned });//sethostnamewhenusinganon-premiseportal(defaultisArcgisOnline) //esriConfig.portalUrl="http://myHostName.esri.com/arcgis"; //whilethisexampleusesFeatureLayer,thissamepatterncanbe //usedforSceneLayers varlyr=newFeatureLayer({ portalItem:{//autocastsasnewPortalItem() id:"8d26f04f31f642b6828b7023b84c2188" }, //loadsthethirditeminthegivenfeatureservice layerId:2 });rendererRendererTherendererassignedtothelayer.Therendererdefineshowtovisualizeeachfeatureinthelayer.Dependingontherenderertype,featuresmaybevisualizedwiththesamesymbol,orwithvaryingsymbolsbasedonthevaluesofprovidedattributefieldsorfunctions.Seealso:CreatingvisualizationsmanuallyExample://allfeaturesinthelayerwillbevisualizedwith //a6ptblackmarkersymbolandathin,whiteoutline layer.renderer=newSimpleRenderer({ symbol:newSimpleMarkerSymbol({ size:6, color:"black", outline:{ width:0.5, color:"white" } }) });returnMBooleanWhentrue,indicatesthatMvalueswillbereturned.DefaultValue:falsereturnZBooleanWhentrue,indicatesthatZvalueswillbereturned.DefaultValue:falsescreenSizePerspectiveEnabledBooleanSince:ArcGISAPIforJavaScript4.4Applyperspectivescalingtoscreen-sizepointsymbolsinaSceneView.Whentrue,screensizedobjectssuchasicons,labelsorcalloutsintegratebetterinthe3Dscenebyapplyingacertainperspectiveprojectiontothesizingoffeatures.ThisonlyapplieswhenusingaSceneView.layer.screenSizePerspectiveEnabled=truelayer.screenSizePerspectiveEnabled=falseKnownLimitationsScreensizeperspectiveiscurrentlynotoptimizedforsituationswherethecameraisveryneartheground,orforsceneswithpointfeatureslocatedfarfromthegroundsurface.Inthesecasesitmaybebettertoturnoffscreensizeperspective.Asscreensizeperspectivechangesthesizebasedondistancetothecamera,itshouldbesettofalsewhenusingsizevisualvariables.DefaultValue:trueSeealso:Sample:PointstylesforcitiessourceCollectionautocastAcollectionofGraphicobjectsusedtocreateaFeatureLayer.ThispropertyshouldonlyusedwhencreatingaFeatureLayerfromclient-sidegraphics.WhencreatingaFeatureLayerfromclient-sidegraphics,thefields,objectIdField,spatialReference,andgeometryTypepropertiesmustalsobeset.Example:varfeatures=[ { geometry:newPoint({ x:-100, y:38 }), attributes:{ ObjectID:1, DepArpt:"KATL", MsgTime:Date.now(), FltId:"UAL1" } }, { geometry:newPoint({ x:-77, y:35 }), attributes:{ ObjectID:2, DepArpt:"KZBW", MsgTime:Date.now(), FltId:"SW999" } }, { geometry:newPoint({ x:-120, y:40 }), attributes:{ ObjectID:3, DepArpt:"WKRP", MsgTime:Date.now(), FltId:"Fever1" } } ]; varlyr=newFeatureLayer({ source:features,//autocastasanarrayofesri/Graphic ... });spatialReferenceSpatialReferenceautocastThespatialreferenceofthelayer.Whencreatingthelayerfromaurl,thespatialreferenceisreadfromtheservice.ThispropertyshouldbesetexplicitlywhencreatingaFeatureLayerfromclient-sidegraphics.WhencreatingaFeatureLayerfromclient-sidegraphics,thefields,objectIdField,source,andgeometryTypepropertiesmustalsobeset.templatesFeatureTemplate[]Since:ArcGISAPIforJavaScript4.4Anarrayoffeaturetemplatesdefinedinthefeaturelayer.SeeArcGISProsubtypesdocument.titleStringThetitleofthelayerusedtoidentifyitinplacessuchastheLegendandLayerListwidgets.Whenloadingalayerbyserviceurl,thetitleisderivedfromtheservicename.Iftheservicehasseverallayers,thenthetitleofeachlayerwillbetheconcatenationoftheservicenameandthelayername.Whenthelayerisloadedfromaportalitem,thetitleoftheportalitemwillbeusedinstead.Finally,ifalayerisloadedaspartofawebmaporawebscene,thenthetitleofthelayerasstoredinthewebmap/webscenewillbeused.tokenStringreadonlyTokengeneratedbythetokenserviceusingthespecifieduserIdandpassword.TherecommendedapproachtopassatokenonalayeristouseIdentityManager.registerToken().typeStringreadonlyForFeatureLayerthetypeisfeature.typeIdFieldStringSince:ArcGISAPIforJavaScript4.4ThenameofthefieldholdingthetypeIDorsubtypesforthefeatures.SeeArcGISProsubtypesdocument.typesFeatureType[]Since:ArcGISAPIforJavaScript4.4AnarrayofsubtypesdefinedinthefeatureserviceexposedbyArcGISRESTAPI.Eachitemincludesinformationaboutthetype,suchasthetypeID,name,anddefinitionexpression.urlStringTheURLoftheRESTendpointofthelayerorservice.TheURLmayeitherpointtoaresourceonArcGISforServer,PortalforArcGIS,orArcGISOnline.Iftheurlpointsdirectlytoaservice,thenthelayermustbespecifiedinthelayerIdproperty.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 varlyr=newFeatureLayer({ //Noticethattheurldoesn'tendwith/2 url:"http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/MonterreyBayCanyon_WFL/FeatureServer", layerId:2 });versionNumberreadonlyTheversionofArcGISServerinwhichthelayerispublished.Example://Printstheversionnumbertotheconsole-e.g.10.2,10.3,10.41,etc. console.log(layer.version);visibleBooleanIndicatesifthelayerisvisibleintheView.Whenfalse,thelayermaystillbeaddedtoaMapinstancethatisreferencedinaview,butitsfeatureswillnotbevisibleintheview.DefaultValue:trueExample://Thelayerisnolongervisibleintheview layer.visible=false;MethodOverviewNameReturnTypeSummaryalways()PromiseAninstanceofthisclassisaPromise.moredetailsmoredetailsapplyEdits()PromiseApplieseditstofeaturesinafeaturelayer.moredetailsmoredetailscancelLoad()Cancelsaload()operationifitisalreadyinprogress.moredetailsmoredetailscreateQuery()QueryCreatesqueryparametersthatcanbeusedtofetchfeaturesthatsatisfythelayer'scurrentfilters,anddefinitions.moredetailsmoredetailsfetchAttributionData()PromiseFetchescustomattributiondataforthelayerwhenitbecomesavailable.moredetailsmoredetailsgetFieldDomain()DomainReturnstheDomainassociatedwiththegivenfieldname.moredetailsmoredetailshasEventListener()BooleanIndicateswhetherthereisaneventlistenerontheinstancethatmatchestheprovidedeventname.moredetailsmoredetailsisFulfilled()BooleanAninstanceofthisclassisaPromise.moredetailsmoredetailsisRejected()BooleanAninstanceofthisclassisaPromise.moredetailsmoredetailsisResolved()BooleanAninstanceofthisclassisaPromise.moredetailsmoredetailsload()PromiseLoadstheresourcesreferencedbythisclass.moredetailsmoredetailson()ObjectRegistersaneventhandlerontheinstance.moredetailsmoredetailsotherwise()PromiseAninstanceofthisclassisaPromise.moredetailsmoredetailsqueryExtent()PromiseExecutesaQueryagainstthefeatureserviceandreturnstheExtentoffeaturesthatsatisfythequery.moredetailsmoredetailsqueryFeatureCount()PromiseExecutesaQueryagainstthefeatureserviceandreturnsthenumberoffeaturesthatsatisfythequery.moredetailsmoredetailsqueryFeatures()PromiseExecutesaQueryagainstthefeatureserviceandreturnsaFeatureSet,whichcanbeaccessedusingthe.then()methodoncethepromiseresolves.moredetailsmoredetailsqueryObjectIds()PromiseExecutesaQueryagainstthefeatureserviceandreturnsanarrayofObjectIDsforfeaturesthatsatisfytheinputquery.moredetailsmoredetailsthen()PromiseAninstanceofthisclassisaPromise.moredetailsmoredetailsMethodDetailsalways(callbackOrErrback){Promise}inheritedAninstanceofthisclassisaPromise.Thereforealways()maybeusedtoexecuteafunctionifthepromiseisrejectedorresolved.Theinputfunctionwillalwaysexecutenomattertheresponse.Formoreinformationaboutpromises,seetheWorkingwithPromisesguidepage.Parameter:callbackOrErrbackFunctionoptionalThefunctiontoexecutewhenthepromiseisrejectedorresolved.Returns:TypeDescriptionPromiseReturnsanewpromisefortheresultofcallbackOrErrback.Example://AlthoughthisexampleusesMapView,anyclassinstancethatisapromisemayusealways()inthesameway varview=newMapView(); view.always(function(){ //Thisfunctionwillalwaysexecutewhetherornotthepromiseisresolvedorrejected });applyEdits(edits){Promise}Applieseditstofeaturesinafeaturelayer.Newfeaturescanbecreatedandexistingfeaturescanbeupdatedordeleted.Featuregeometriesand/orattributesmaybemodified.Onlyapplicabletolayersinafeatureservice.Parameters:editsObjectObjectcontainingfeaturestobeadded,updatedordeleted.Specification:addFeaturesGraphic[]optionalArrayoffeaturestobeadded.Valuesofnonnullablefieldsmustbeprovidedwhenaddingnewfeatures.Datefieldsmusthavenumericvaluesrepresentinguniversaltime.updateFeaturesGraphic[]optionalArrayoffeaturestobeupdated.EachfeaturemusthavevalidobjectId.Valuesofnonnullablefieldsmustbeprovidedwhenupdatingfeatures.Datefieldsmusthavenumericvaluesrepresentinguniversaltime.deleteFeaturesGraphic[]|Object[]optionalAnarrayoffeaturesorobjectstobedeleted.Whenanarrayoffeaturesispassed,eachfeaturemusthaveavalidobjectId.Whenanarrayofobjectsisused,eachobjectmusthaveavalidobjectIdproperty.Returns:TypeDescriptionPromiseResolvestoanobjectcontainingeditresults.Seetheobjectspecificationtablebelowfordetails.PropertyTypeDescriptionaddFeatureResultsFeatureEditResult[]Resultofaddingfeatures.deleteFeatureResultsFeatureEditResult[]Resultofdeletingfeatures.updateFeatureResultsFeatureEditResult[]Resultofupdatingfeatures.Seealso:Sample-EditfeaturesExample:functionaddFeature(geometry){ varattributes={}; attributes["Description"]="Thisisthedescription"; attributes["Address"]="380NewYorkSt"; //Date.now()returnsnumberofmillisecondselapsed //since1January197000:00:00UTC. attributes["Report_Date"]=Date.now(); varaddFeature=newGraphic({ geometry:geometry, attributes:attributes }); vardeleteFeature={ objectId:467 }; varpromise=featureLayer.applyEdits({ addFeatures:[addFeature], deleteFeatures:[deleteFeature] }); }cancelLoad()inheritedCancelsaload()operationifitisalreadyinprogress.createQuery(){Query}Createsqueryparametersthatcanbeusedtofetchfeaturesthatsatisfythelayer'scurrentfilters,anddefinitions.Returns:TypeDescriptionQueryThequeryobjectrepresentingthelayer'sfiltersandotherdefinitions.Seealso:Sample-QueryfeaturesfromaFeatureLayerExample://Getaqueryobjectforthelayer'scurrentconfiguration varqueryParams=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); });fetchAttributionData(){Promise}inheritedFetchescustomattributiondataforthelayerwhenitbecomesavailable.Returns:TypeDescriptionPromiseResolvestoanobjectcontainingcustomattributiondataforthelayer.getFieldDomain(fieldName,options){Domain}ReturnstheDomainassociatedwiththegivenfieldname.ThedomaincanbeeitheraCodedValueDomainorRangeDomain.Parameters:fieldNameStringNameofthefield.optionsObjectoptionalAnobjectspecifyingadditionaloptions.Seetheobjectspecificationtablebelowfortherequiredpropertiesofthisobject.Specification:featureGraphicThefeaturetowhichtheDomainisassigned.Returns:TypeDescriptionDomainTheDomainobjectassociatedwiththegivenfieldnameforthegivenfeature.Example://Getarangedomainassociatedwiththefirstfeature //returnedfromqueryFeatures(). featureLayer.queryFeatures(query).then(function(results){ vardomain=featureLayer.getFieldDomain("Height",{feature:results.features[0]}); console.log("domain",domain) });hasEventListener(type){Boolean}inheritedIndicateswhetherthereisaneventlistenerontheinstancethatmatchestheprovidedeventname.Parameter:typeStringThenameoftheevent.Returns:TypeDescriptionBooleanReturnstrueiftheclasssupportstheinputevent.isFulfilled(){Boolean}inheritedAninstanceofthisclassisaPromise.ThereforeisFulfilled()maybeusedtoverifyifthepromiseisfulfilled(eitherresolvedorrejected).Ifitisfulfilled,truewillbereturned.SeetheWorkingwithPromisesguidepageformoreinformationaboutpromises.Returns:TypeDescriptionBooleanIndicateswhetherthepromisehasbeenfulfilled(eitherresolvedorrejected).isRejected(){Boolean}inheritedAninstanceofthisclassisaPromise.ThereforeisRejected()maybeusedtoverifyifthepromiseisrejected.Ifitisrejected,truewillbereturned.SeetheWorkingwithPromisesguidepageformoreinformationaboutpromises.Returns:TypeDescriptionBooleanIndicateswhetherthepromisehasbeenrejected.isResolved(){Boolean}inheritedAninstanceofthisclassisaPromise.ThereforeisResolved()maybeusedtoverifyifthepromiseisresolved.Ifitisresolved,truewillbereturned.SeetheWorkingwithPromisesguidepageformoreinformationaboutpromises.Returns:TypeDescriptionBooleanIndicateswhetherthepromisehasbeenresolved.load(){Promise}inheritedLoadstheresourcesreferencedbythisclass.ThismethodautomaticallyexecutesforaViewandalloftheresourcesitreferencesinMapiftheviewisconstructedwithamapinstance.ThismethodmustbecalledbythedeveloperwhenaccessingaresourcethatwillnotbeloadedinaView.Returns:TypeDescriptionPromiseResolveswhentheresourceshaveloaded.on(type,listener){Object}inheritedRegistersaneventhandlerontheinstance.Callthismethodtohookaneventwithalistener.SeetheEventssummarytableforalistoflistenedevents.Parameters:typeStringThenameofeventtolistenfor.listenerFunctionThefunctiontocallwhentheeventisfired.Returns:TypeDescriptionObjectReturnsaneventhandlerwitharemove()methodthatcanbecalledtostoplisteningfortheevent.PropertyTypeDescriptionremoveFunctionWhencalled,removesthelistenerfromtheevent.Seealso:dojo/onExample:view.on("click",function(event){ //eventistheeventhandlereturnedaftertheeventfires. console.log(event.mapPoint); });otherwise(errback){Promise}inheritedAninstanceofthisclassisaPromise.Useotherwise()tocallafunctiononcethepromiseisrejected.Parameter:errbackFunctionoptionalThefunctiontoexecutewhenthepromisefails.Returns:TypeDescriptionPromiseReturnsanewpromisefortheresultoferrback.Example://AlthoughthisexampleusesMapView,anyclassinstancethatisapromisemayuseotherwise()inthesameway varview=newMapView(); view.otherwise(function(error){ //Thisfunctionwillexecuteifthepromiseisrejectedduetoanerror });queryExtent(params){Promise}ExecutesaQueryagainstthefeatureserviceandreturnstheExtentoffeaturesthatsatisfythequery.Ifnoparametersarespecified,thentheextentandcountofallfeaturessatisfyingthelayer'sconfiguration/filtersarereturned.Thisisvalidonlyforhostedfeatureservicesonarcgis.comandforArcGISServer10.3.1andlater.Toqueryfortheextentoffeatures/graphicsavailabletoorvisibleintheViewontheclientratherthanmakingaserver-sidequery,youmustusetheFeatureLayerView.queryExtent()method.Parameter:paramsQueryoptionalSpecifiestheattributesandspatialfilterofthequery.Ifnoparametersarespecified,thentheextentandcountofallfeaturessatisfyingthelayer'sconfiguration/filtersarereturned.IfworkingwithaFeatureLayercreatedfromaFeatureCollection(viasource),onlythegeometry,objectIds,andspatialRelationshippropertiesshouldbespecified.Addinganyotherpropertieswillreturnanerror.IfspecifyingaspatialRelationship,notethatintersectsistheonlysupportedoperation.Returns:TypeDescriptionPromiseWhenresolved,returnstheextentandcountofthefeaturesthatsatisfytheinputquery.Seetheobjectspecificationtablebelowfordetails.PropertyTypeDescriptioncountNumberThenumberoffeaturesthatsatisfytheinputquery.extentExtentTheextentofthefeaturesthatsatisfythequery.Examples://Queriesfortheextentofallfeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryExtent().then(function(results){ //gototheextentoftheresultssatisfyingthequery view.goTo(results.extent); });varlyr=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); varquery=newQuery(); query.where="region='SouthernCalifornia'"; lyr.queryExtent(query).then(function(results){ view.goTo(results.extent);//gototheextentoftheresultssatisfyingthequery });queryFeatureCount(params){Promise}ExecutesaQueryagainstthefeatureserviceandreturnsthenumberoffeaturesthatsatisfythequery.Ifnoparametersarespecified,thenthetotalnumberoffeaturessatisfyingthelayer'sconfiguration/filtersisreturned.Toqueryforthecountoffeatures/graphicsavailabletoorvisibleintheViewontheclientratherthanmakingaserver-sidequery,youmustusetheFeatureLayerView.queryFeatureCount()method.Parameter:paramsQueryoptionalSpecifiestheattributesandspatialfilterofthequery.Ifnoparametersarespecified,thenthetotalnumberoffeaturessatisfyingthelayer'sconfiguration/filtersisreturned.IfworkingwithaFeatureLayercreatedfromaFeatureCollection(viasource),onlythegeometry,objectIds,andspatialRelationshippropertiesshouldbespecified.Addinganyotherpropertieswillreturnanerror.IfspecifyingaspatialRelationship,notethatintersectsistheonlysupportedoperation.Returns:TypeDescriptionPromiseWhenresolved,returnsanthenumberoffeaturessatisfyingthequery.Examples://Queriesforthecountofallfeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryFeatureCount().then(function(numFeatures){ //printsthetotalcounttotheconsole console.log(numFeatures); });varlyr=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); varquery=newQuery(); query.where="region='SouthernCalifornia'"; lyr.queryFeatureCount(query).then(function(numResults){ console.log(numResults);//printsthenumberofresultssatisfyingthequery });queryFeatures(params){Promise}ExecutesaQueryagainstthefeatureserviceandreturnsaFeatureSet,whichcanbeaccessedusingthe.then()methodoncethepromiseresolves.AFeatureSetcontainsanarrayofGraphicfeatures,whichcanbeaddedtotheview'sgraphics.Thisarraywillnotbepopulatedifzeroresultsarefound.Toqueryfeatures/graphicsavailabletoorvisibleintheViewontheclientratherthanmakingaserver-sidequery,youmustusetheFeatureLayerView.queryFeatures()method.Parameter:paramsQueryoptionalSpecifiestheattributesandspatialfilterofthequery.Ifnoparametersarespecified,thenallfeaturessatisfyingthelayer'sconfiguration/filtersarereturned.IfworkingwithaFeatureLayercreatedfromaFeatureCollection(viasource),onlythegeometry,objectIds,andspatialRelationshippropertiesshouldbespecified.Addinganyotherpropertieswillreturnanerror.IfspecifyingaspatialRelationship,notethatintersectsistheonlysupportedoperation.Returns:TypeDescriptionPromiseWhenresolved,aFeatureSetcontaininganarrayofgraphicfeaturesisreturned.Seealso:Sample-QueryfeaturesfromaFeatureLayerExamples://Queriesforallthefeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryFeatures().then(function(results){ //printsthearrayofresultgraphicstotheconsole console.log(results.features); });varlyr=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); varquery=newQuery(); query.where="STATE_NAME='Washington'"; query.outSpatialReference={wkid:102100}; query.returnGeometry=true; query.outFields=["CITY_NAME"]; lyr.queryFeatures(query).then(function(results){ console.log(results.features);//printsthearrayoffeaturestotheconsole });//Getaqueryobjectforthelayer'scurrentconfiguration varqueryParams=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); });queryObjectIds(params){Promise}ExecutesaQueryagainstthefeatureserviceandreturnsanarrayofObjectIDsforfeaturesthatsatisfytheinputquery.Ifnoparametersarespecified,thentheObjectIDsofallfeaturessatisfyingthelayer'sconfiguration/filtersarereturned.ToqueryforObjectIDsoffeatures/graphicsavailabletoorvisibleintheViewontheclientratherthanmakingaserver-sidequery,youmustusetheFeatureLayerView.queryObjectIds()method.Parameter:paramsQueryoptionalSpecifiestheattributesandspatialfilterofthequery.Ifnoparametersarespecified,thentheObjectIDsofallfeaturessatisfyingthelayer'sconfiguration/filtersarereturned.IfworkingwithaFeatureLayercreatedfromaFeatureCollection(viasource),onlythegeometry,objectIds,andspatialRelationshippropertiesshouldbespecified.Addinganyotherpropertieswillreturnanerror.IfspecifyingaspatialRelationship,notethatintersectsistheonlysupportedoperation.Returns:TypeDescriptionPromiseWhenresolved,returnsanarrayofnumbersrepresentingtheobjectIDsofthefeaturessatisfyingthequery.Examples://QueriesforalltheObjectIDsoffeaturesmatchingthelayer'sconfigurations //e.g.definitionExpression layer.queryObjectIds().then(function(results){ //printsthearrayofObjectIDstotheconsole console.log(results); });varlyr=newFeatureLayer({ url:fsUrl//pointstoaFeatureServicelayerurl }); varquery=newQuery(); query.where="region='SouthernCalifornia'"; lyr.queryObjectIds(query).then(function(ids){ console.log(ids);//anarrayofobjectIDs });then(callback,errback,progback){Promise}inheritedAninstanceofthisclassisaPromise.Thereforethen()maybeleveragedonceaninstanceoftheclassiscreated.Thismethodtakestwoinputparameters:acallbackfunctionandanerrbackfunction.Thecallbackexecuteswhenthepromiseresolves(whentheinstanceoftheclassloads).Theerrbackexecutesifthepromisefails.SeetheWorkingwithPromisesguidepageforadditionaldetails.Parameters:callbackFunctionoptionalThefunctiontocallwhenthepromiseresolves.errbackFunctionoptionalThefunctiontoexecutewhenthepromisefails.progbackFunctionoptionalThefunctiontoinvokewhenthepromiseemitsaprogressupdate.Returns:TypeDescriptionPromiseReturnsanewpromisefortheresultofcallbackthatmaybeusedtochainadditionalfunctions.Example://AlthoughthisexampleusesMapView,anyclassinstancethatisapromisemayusethen()inthesameway varview=newMapView(); view.then(function(){ //Thisfunctionwillexecuteoncethepromiseisresolved },function(error){ //Thisfunctionwillexecuteifthepromiseisrejectedduetoanerror });TypeDefinitionsFeatureEditResultObjectFeatureEditResultrepresentstheresultofadding,updatingordeletingafeature.Properties:objectIdNumberObjectIdofthefeaturethatwasedited.errorObjectIftheeditfailed,theeditresultincludesanerror.Specification:nameStringErrorname.messageStringMessagedescribingtheerror.EventOverviewNameTypeSummarylayerview-create{view:View,layerView:LayerView}Firesafterthelayer'sLayerViewiscreatedandrenderedinaview.moredetailsmoredetailslayerview-destroy{view:View,layerView:LayerView}Firesafterthelayer'sLayerViewisdestroyedandnolongerrendersinaview.moredetailsmoredetailsEventDetailslayerview-createinheritedFiresafterthelayer'sLayerViewiscreatedandrenderedinaview.Properties:viewViewTheviewinwhichthelayerViewwascreated.layerViewLayerViewTheLayerViewrenderedintheviewrepresentingthelayerinlayer.Seealso:View.whenLayerView()Example://Thisfunctionwillfireeachtimealayerviewiscreatedforthis //particularview. layer.on("layerview-create",function(event){ //TheLayerViewforthelayerthatemittedthisevent event.layerView; });layerview-destroyinheritedFiresafterthelayer'sLayerViewisdestroyedandnolongerrendersinaview.Properties:viewViewTheviewinwhichthelayerViewwasdestroyed.layerViewLayerViewThedestroyedLayerViewrepresentingthelayer.APIReferencesearchresultsNameTypeModuleTherewerenomatchresultsfromyoursearchcriteria.Feedbackonthistopic?



請為這篇文章評分?