Query features from a FeatureLayer - ArcGIS API for JavaScript

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

The queryFeatures() method allows the user to query the features in a FeatureLayer based on an input query object. The createQuery() method is available as a ... GetStartedOverviewLatestSamplesWMTSLayerSelectWMTSsublayerWMSLayerGeneratedata-drivenvisualizationofuniquevaluesGeneratecontinuouscolorvisualizationfor3DbuildingsReferenceArcadeexpressionsinPopupTemplatePopupTemplatewithpromiseHighlightpointfeaturesHighlightSceneLayerPointstylesforcitiesUsingcalloutlineswithlabelsColoringoptionsfortexturedbuildingsIntensitycolormodulationZoomtoextentoffeaturesDisablepanningontheviewDisablerotationontheviewDisablescroll-zoomingontheviewDisableallzoomingontheviewCustomTileLayerCustomDynamicLayerCustomLercLayerCustomBlendLayerCustomElevationLayer-ExaggeratingelevationCustomElevationLayer-ThematicdataaselevationSwapviewfrom2Dto3DDrawpolygonforspatialqueryMeasurewhiledrawingPrintwidgetvectortilesMappingandViewsGetstartedwithMapView(2D)GetstartedwithSceneView(3D)LoadabasicwebmapLoadabasicwebsceneSaveawebsceneWebscene-slidesCreatealocalsceneSceneView-goTo()ViewpaddingCreateacustombasemapSwapwebmapsinthesameviewSwapviewfrom2Dto3DLayersGetstartedwithlayersCreatelayerfromportalitemVectorTileLayerIntegratedMeshLayerStreamLayerCSVLayerOpenStreetMapLayerWebTileLayerWMSLayerWMTSLayerSelectWMTSsublayerGeoRSSLayerFeatureLayerGetstartedwithFeatureLayerDrawingimprovementsCreatedfromarrayofgraphicsFeatureLayerView-queryHighlightpointfeaturesSceneLayerGetstartedwithSceneLayerRealisticbuildingsColoringoptionsfortexturedbuildingsPointgeometriesFilterandquerySceneLayerView-queryHighlightSceneLayerMapImageLayerGetstartedwithMapImageLayerTogglesublayervisibilitySetdefinitionexpressionsonsublayersSetrenderersonsublayersLabelsublayerfeaturesCreatedynamicmaplayersDynamicdatalayerwithtablejoinDynamicdatalayerwithquerytableDynamicdatalayerwithrasterdataImageryLayerGetstartedwithImageryLayerClientsidepixelfilterServersiderasterfunctionClientsiderenderingrulesRasterattributetablePointCloudLayerGetstartedwithPointCloudLayerTogglevisualizationsChangepointsizeanddensityIntensitycolormodulationCustomLayersCustomTileLayerCustomDynamicLayerCustomLercLayerCustomBlendLayerCustomElevationLayer-ExaggeratingelevationCustomElevationLayer-ThematicdataaselevationVisualizationSymbolPlaygroundVisualizefeaturesbyuniquetypesVisualizedatawithclassbreaksGeneratedata-drivencontinuouscolorvisualizationGeneratedata-drivenvisualizationofuniquevaluesGeneratecontinuouscolorvisualizationfor3DbuildingsData-drivencontinuouscolorData-drivencontinuoussizeData-drivenextrusionMultivariatevisualizations(3D)CreateacustomvisualizationusingArcadeVisualizefeatureswithrealisticWebStyleSymbolsPointstylesforcitiesUsingcalloutlineswithlabelsPopupsGetstartedwithpopupsGetstartedwithPopupTemplateDockpopuppositionsMultiplepopupelementsReferenceArcadeexpressionsinPopupTemplatePopupTemplatewithfunctionsPopupTemplatewithpromisePopupactionsCustompopupactionsperfeatureEditingFeatureLayerapplyEditsGraphicsGetstartedwithgraphicsAddgraphicstoaSceneViewSearchingSearchwidgetSearchwidgetwithmultiplesourcesQueryfeaturesfromaFeatureLayerSceneLayer-queryalinkedFeatureLayerQueryTaskFindTaskIdentifyTaskAnalysisGeometryEngine-geodesicbuffersGeoprocessing-viewshedanalysisGeoprocessing-hotspotanalysisRouteTaskQueryElevation(points)QueryElevation(lines)WidgetsGetstartedwithwidgetsBasemapGallerywidgetLayerListwidgetLayerListwidgetwithactionsLegendwidgetLocatebuttonPrintwidgetPrintwidgetvectortilesTrackcurrentlocationTrackwidgetsimulationExpandwidgetUsingtheview'sUIResponsivewidgetsWidgets(Advanced)CreateacustomwidgetCustomRecenterwidgetUsingwidgetswithAngularUsingwidgetswithReactUsingwidgetswithRiotCustomwidgetswithVueMore3DTogglegroundelevationLookaroundcamerapositionRealisticenvironmentsettingsSceneView-environmentsettingsElevationoffsetElevationLayerSatellitesin3DviewWorkflowsGetstartedwithWorkflowManagerOtherDrawpolygonforspatialqueryMeasurewhiledrawingRequestdatafromaremoteserverAccessArcGISOnlineitemsviaOAuthChainingpromisesAccessfeatureswithclickeventsSynchronizeMapViewandSceneViewCalciteMapsandBootstrapUsingEsriIconFontsWatchforchangesZoomtoextentoffeaturesDraganddropportalitemsDisablepanningontheviewDisablerotationontheviewDisablescroll-zoomingontheviewDisableallzoomingontheviewBacktoTopOverviewWMTSLayerSelectWMTSsublayerWMSLayerGeneratedata-drivenvisualizationofuniquevaluesGeneratecontinuouscolorvisualizationfor3DbuildingsReferenceArcadeexpressionsinPopupTemplatePopupTemplatewithpromiseHighlightpointfeaturesHighlightSceneLayerPointstylesforcitiesUsingcalloutlineswithlabelsColoringoptionsfortexturedbuildingsIntensitycolormodulationZoomtoextentoffeaturesDisablepanningontheviewDisablerotationontheviewDisablescroll-zoomingontheviewDisableallzoomingontheviewCustomTileLayerCustomDynamicLayerCustomLercLayerCustomBlendLayerCustomElevationLayer-ExaggeratingelevationCustomElevationLayer-ThematicdataaselevationSwapviewfrom2Dto3DDrawpolygonforspatialqueryMeasurewhiledrawingPrintwidgetvectortilesGetstartedwithMapView(2D)GetstartedwithSceneView(3D)LoadabasicwebmapLoadabasicwebsceneSaveawebsceneWebscene-slidesCreatealocalsceneSceneView-goTo()ViewpaddingCreateacustombasemapSwapwebmapsinthesameviewSwapviewfrom2Dto3DGetstartedwithlayersCreatelayerfromportalitemVectorTileLayerIntegratedMeshLayerStreamLayerCSVLayerOpenStreetMapLayerWebTileLayerWMSLayerWMTSLayerSelectWMTSsublayerGeoRSSLayerGetstartedwithFeatureLayerDrawingimprovementsCreatedfromarrayofgraphicsFeatureLayerView-queryHighlightpointfeaturesGetstartedwithSceneLayerRealisticbuildingsColoringoptionsfortexturedbuildingsPointgeometriesFilterandquerySceneLayerView-queryHighlightSceneLayerGetstartedwithMapImageLayerTogglesublayervisibilitySetdefinitionexpressionsonsublayersSetrenderersonsublayersLabelsublayerfeaturesCreatedynamicmaplayersDynamicdatalayerwithtablejoinDynamicdatalayerwithquerytableDynamicdatalayerwithrasterdataGetstartedwithImageryLayerClientsidepixelfilterServersiderasterfunctionClientsiderenderingrulesRasterattributetableGetstartedwithPointCloudLayerTogglevisualizationsChangepointsizeanddensityIntensitycolormodulationCustomTileLayerCustomDynamicLayerCustomLercLayerCustomBlendLayerCustomElevationLayer-ExaggeratingelevationCustomElevationLayer-ThematicdataaselevationSymbolPlaygroundVisualizefeaturesbyuniquetypesVisualizedatawithclassbreaksGeneratedata-drivencontinuouscolorvisualizationGeneratedata-drivenvisualizationofuniquevaluesGeneratecontinuouscolorvisualizationfor3DbuildingsData-drivencontinuouscolorData-drivencontinuoussizeData-drivenextrusionMultivariatevisualizations(3D)CreateacustomvisualizationusingArcadeVisualizefeatureswithrealisticWebStyleSymbolsPointstylesforcitiesUsingcalloutlineswithlabelsGetstartedwithpopupsGetstartedwithPopupTemplateDockpopuppositionsMultiplepopupelementsReferenceArcadeexpressionsinPopupTemplatePopupTemplatewithfunctionsPopupTemplatewithpromisePopupactionsCustompopupactionsperfeatureFeatureLayerapplyEditsGetstartedwithgraphicsAddgraphicstoaSceneViewSearchwidgetSearchwidgetwithmultiplesourcesQueryfeaturesfromaFeatureLayerSceneLayer-queryalinkedFeatureLayerQueryTaskFindTaskIdentifyTaskGeometryEngine-geodesicbuffersGeoprocessing-viewshedanalysisGeoprocessing-hotspotanalysisRouteTaskQueryElevation(points)QueryElevation(lines)GetstartedwithwidgetsBasemapGallerywidgetLayerListwidgetLayerListwidgetwithactionsLegendwidgetLocatebuttonPrintwidgetPrintwidgetvectortilesTrackcurrentlocationTrackwidgetsimulationExpandwidgetUsingtheview'sUIResponsivewidgetsCreateacustomwidgetCustomRecenterwidgetUsingwidgetswithAngularUsingwidgetswithReactUsingwidgetswithRiotCustomwidgetswithVueTogglegroundelevationLookaroundcamerapositionRealisticenvironmentsettingsSceneView-environmentsettingsElevationoffsetElevationLayerSatellitesin3DviewGetstartedwithWorkflowManagerDrawpolygonforspatialqueryMeasurewhiledrawingRequestdatafromaremoteserverAccessArcGISOnlineitemsviaOAuthChainingpromisesAccessfeatureswithclickeventsSynchronizeMapViewandSceneViewCalciteMapsandBootstrapUsingEsriIconFontsWatchforchangesZoomtoextentoffeaturesDraganddropportalitemsDisablepanningontheviewDisablerotationontheviewDisablescroll-zoomingontheviewDisableallzoomingontheviewQueryfeaturesfromaFeatureLayerLoadingsamplehere...Thisdevicedoesnotsupport3D.Viewthesystemrequirementsformoreinformation.ExploreinthesandboxJSBinViewliveThissampledemonstratesvariouswaystoqueryaFeatureLayer.Itusespointfeaturesrepresentingoilandgaswellsinrelationtoearthquakedata.Thesampleallowstheusertosetqueryparametersincludingattributequeriesandaspatialquery.HowitworksWhentheapplicationstarts,aUIdisplaysoptionsforuserinput.Here,specifythetypeofoilorgaswelltoquery,thedistancetobufferaroundthesewells,andlastly,aminimummagnitudelevelforanyearthquakesthathaveoccurredwithinthebufferedvicinity.TheFeatureLayerhasseveralmethodsforqueryingdata.ThequeryFeatures()methodallowstheusertoquerythefeaturesinaFeatureLayerbasedonaninputqueryobject.ThecreateQuery()methodisavailableasaconveniencetotheuser.Itreturnsaqueryobjectthatalreadyrespectthelayer'sdefinitionExpressionifoneispresent.//queryallfeaturesfromtheoilandgaswellslayer view.then(function(){ returnwellsLayer.then(function(){ varquery=wellsLayer.createQuery(); returnwellsLayer.queryFeatures(query); }); }) Anarrayofdistinctvaluesisthengeneratedfromanattribute,i.e.STATUS2,inthewellslayer.ThesevaluesareprovidedasadropdownintheUIandallowstheusertofilterthewellsbytype.Next,setthedefinitionexpressiononthewellslayertoreflecttheuser'sselectionfromtheUI.functionsetWellsDefinitionExpression(newValue){ wellsLayer.definitionExpression="STATUS2='"+newValue+"'"; if(!wellsLayer.visible){ wellsLayer.visible=true; } returnqueryForWellGeometries(); } Nowqueryallthegeometriesofthewellslayer.ThecreateQuerymethodcreatesaqueryobjectthatrespectsthedefinitionexpressionsetonthelayerfromthepreviousstep.functionqueryForWellGeometries(){ varwellsQuery=wellsLayer.createQuery(); returnwellsLayer.queryFeatures(wellsQuery).then(function(response){ wellsGeometries=response.features.map(function(feature){ returnfeature.geometry; }); returnwellsGeometries; }); } Asinglepolygonbufferisthengeneratedaroundthesereturnedwellgeometries.Thebuffer'sdistanceisdeterminedbasedontheuserinput.Lastly,queryforanyearthquakesthatmeetthespecifiedminimummagnitudeandfallwithinthebufferedgeometry.Thisqueryusesbothattributeparametersforthewhereclauseinadditiontoaspatialqueryfindingallearthquakesthatintersectthegeneratedbuffer.on(dom.byId("query-quakes"),"click",function(){ queryEarthquakes().then(displayResults); }); functionqueryEarthquakes(){ varquery=quakesLayer.createQuery(); query.where="mag>="+magSlider.value; query.geometry=wellBuffer; query.spatialRelationship="intersects"; returnquakesLayer.queryFeatures(query); } NotethatFeatureLayerscreatedfromclient-sidegraphicscanonlybequeriedusingthequerymethodsavailableontheFeatureLayerView.Tags2D,queryFeatures,FeatureLayer,Query,4.1SamplesearchresultsTitleSampleTherewerenomatchresultsfromyoursearchcriteria.Feedbackonthistopic?



請為這篇文章評分?