change WHERE clause in <esri:FeatureLayer  and zoom to

2458
12
09-27-2012 11:59 AM
AshakaThakore
New Contributor II
I have a silverlight application in which i have added a Map with a featurelayer

<esri:FeatureLayer   ID="MyFeatLayer" Visible="True"  Mode="OnDemand"  
                    Url="http://mymachine/arcgisserver/rest/services/mymapservice/MapServer/0"                                               
                     OutFields="G_KEY_COMP,OBJECTID,StreetAddressIdentify,gridnumber"
                     />

now my use selects an attribute-like a grid number, then in the code behind, i change MyFeatLayer's where clause using -
  myfeatlayer = (FeatureLayer)this.MyMap1.Layers["MyFeatLayer"];
                    this.MyMap1.Layers["MyFeatLayer"].Visible = true;
              
                myfeatlayer.Where = "gridnumber =100  ";
               
                myfeatlayer.Update();

Now how do I zoom to that particular feature layer so that it just shows what is currently inside the feature-layer(i.e. with where clause)

I did this
  this.MyMap1.Extent = myfeatlayer.FullExtent;

But it did not work

pl help
0 Kudos
12 Replies
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
0 Kudos
AshakaThakore
New Contributor II
thanks so much andrew,

also i found that <esri:Featurelayer takes long time  to load

is that a proper way what i am doing  or give me tips
My aim is to
1. allow user to put in a where clause and
2. just show the features that meet that where clause
thats it...

pl help

thanks so much
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Check out the QueryTask sample:
http://help.arcgis.com/en/webapi/silverlight/help/index.html#//01660000001t000000

you could pass the geometry of the result to a graphics layer to symbolize your selection
0 Kudos
AshakaThakore
New Contributor II
thanks again...

if i do a query task, i have to define symbols for my graphics in the graphics layer
NowI have limited choice of symbols , I have to use the symbols available in arcmap (hazardouous waste symbols) in my graphics layer...

Is that possible?


Or if that is not workable I might have to go with justing using <esri:featurelayer and change where clause... but do i have to specify renderer for the <esri:featurelayer or it display the layer with the same symbols as in the arcmap document using which that feature-service is generated.

pl help

thanks...
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
If you have a limited set of symbols, you can store them as image resources in your application (*.png) then apply a picture marker symbol to the graphic's symbology:
  <esri:PictureMarkerSymbol x:Key="CoordinatePictureSymbol" OffsetX="0" OffsetY="34"
                              Source="/MyApplication;component/ResourceImages/HazMat.png"/>


If you go with FeatureLayer route-  I think that it should inherit the default symbology from your map document.  If not, then you will need to define a custom renderer for your FeatureLayer. You could use the above mentioned code to define your resources and apply them as a custom renderer.  This sample should help:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerRendering
0 Kudos
AshakaThakore
New Contributor II
thanks a lot..

Pl advice which one is better? using <esri:featurelayer where clause
or doing a query

Thanks again
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
thanks a lot..

Pl advice which one is better? using <esri:featurelayer where clause
or doing a query

Thanks again


"Which one is better" really depends on your use case.  If you're going to be editing, then FeatureLayer is the way to go.  For simple display purposes, then the Graphics Layer may perform better.  Don't forget to mark any threads as "answered" so that anybody with the same issue will know where to find the best result.
0 Kudos
AshakaThakore
New Contributor II
thanks andrew, i am plannign to go with the Graphics Way as I am not going to edit the Feature

but how can i use the symbologies that we have in arcmap in the graphics layer...

I saw the picturemarker symbol but I dont know how to extract the images/pictures inside the symbologies we have in arcmap... 

I cannot use bitmap, i need kind of transparent images....
Pl help

thanks a lot
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The performances by using a featureLayer (in snapshot mode) or by using a query should be very close (and likely identical).

Using a FeatureLayer is effectively better because you get the symbology coming from the server.

In your case, the performance are likely different because you are using the 'OnDemand' mode. With this mode a query is sent for every zoom or pan.

If your number of features (after filtering) is not too high (i.e < a few 1000s), you can use the snapshot mode.
In this mode only one query will be sent and performances will be better.
0 Kudos