Definition Query for Service Layers?

5611
5
08-01-2013 05:48 AM
JonBarlett
New Contributor
According to build 1500, you can create a defnition query for a service layer:
http://blogs.esri.com/esri/arcgis/2010/08/24/what-s-new-in-arcgis-explorer-build-1500/

"�?�Definition query on feature and service layers"

I have figure out how to apply a definition query to a feature layer:

Dim theMap As Map = Application.ActiveMapDisplay.Map
Dim fLayer As FeatureLayer = TryCast(theMap.FindByName("CrimePart1_28Days"), FeatureLayer)
fLayer.QueryDefinition = "DIVISION = 'NORTH CENTRAL'"

I just haven't figured out how to apply a definition query to a service child service layer. 

Very new to ArcExplorer SDK- any help would be appreciated

Jon Barlett
GIS Analyst
Dallas Police
0 Kudos
5 Replies
T__WayneWhitley
Frequent Contributor
Not sure - your query looks okay, but try:
Dim theMap As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
Dim fLayer As FeatureLayer = TryCast(theMap.Map.FindByName("CrimePart1_28Days"), FeatureLayer)
fLayer.QueryDefinition = "DIVISION = 'NORTH CENTRAL'"


...provided the text provided in your example is 'good'.

Got this directly from the .NET example here, so at least you'll have a webhelp point of reference:
http://help.arcgis.com/en/arcgisexplorer/1500/sdk/componenthelp/index.html#//000300000sn9000000


Enjoy,
Wayne
0 Kudos
JonBarlett
New Contributor
Thanks Wayne,

Yes, the code included works for a feature layer.  I am trying to figure out how to construct code to perform a definition query on a service layer.  Maybe this is not possible?

As a backup plan, I am trying to create a query from the service layer and add it to the map as a featurelayer.  The following code creates the feature layer and adds it to AE, but the source is broken.  I just want the ability ot query a "service layer" and view it in AE with its native symbology, which seems to be limited to a featurelayer. 

Dim player As ServiceChildLayer
player = theMap.FindByName("Reporting_Areas")
Dim WhereClause As String
whereClause = "RA = '1002'"
Dim featureLayer As FeatureLayer = player.Query(WhereClause)
theMap.ChildItems.Add(featureLayer)

Thanks
Jon
0 Kudos
ShannonDeArmond
Occasional Contributor

Hi Jon. Did you ever find a solution to this problem? I am trying to accomplish the same feat.

-Shannon

0 Kudos
JonBarlett
New Contributor

Shannon,

Sorry for the delay, I have been out of pocket for a while.  Just wanted to replay let you know that I did not get this to work.

Thanks

0 Kudos
T__WayneWhitley
Frequent Contributor
Looks possible, although I haven't tried any code.  See this doc below for 2500 and try cobbling something similar together for yours.  Actually, this is stated available for 1500 so I haven't a clue why it wouldn't be in the 1500 webhelp --- after the 'this is new' header, there's the statement:

"The API has not been changed for the latest release. This topic lists the new API types and members which were introduced in ArcGIS Explorer 1500."

New API Types and Members
http://help.arcgis.com/en/arcgisexplorer/2500/sdk/conceptualhelp/index.html#//000200000060000000

Search the page for the phrase, "ServiceChildLayer supports queries" which includes this listing for props/methods and you'll probably want to use CanQuery to verify if it's possible:

public sealed class ESRI.ArcGISExplorer.Mapping.ServiceChildLayer
Property: bool CanQuery { public get; }
Method (i): public MapItem Clone ()
Property: ColumnCollection Columns { public get; }
Method: public bool Contains (MapItem item)
Method: public MapItem FindById (Guid id)
Method: public MapItem FindByName (string name)
Method: public ReadOnlyCollection GetMapItems (T)
Property: IEnumerable { Type } Descendants { public get; }
Property: IEnumerable { Type } DescendantsBottomUp { public get; }
Property: Bitmap Icon { public get; public set; }
Property: int QueryFeatureLimit { public get; }
Method: public FeatureLayer Query (string whereClause)
Method: public int QueryFeatureCount (string whereClause)


Hope that steers you correctly!

Wayne
0 Kudos