Select to view content in your preferred language

FeatureLayer has no graphics collection unless I give it to the Map ...

3686
12
09-09-2012 03:58 AM
Labels (1)
MikeShaw
New Contributor
All,

I have the need to create a FeatureLayer (local or not) and gain access to its Features --without the use of a Map--.  I haven't been successful.  The following steps are what I assumed would work:

1.  Create a LocalFeatureService.
2.  Point it towards a valid MapPackage file.
3.  Start the Service.
4.  On StartCompleted -> Create a LocalFeatureLayer.
5.  Give the LocalFeatureLayer the 'Service' and a valid 'LayerName' (a corresponding, editable layer within the MapPackage).
6.  Initialize the Layer.
7.  OnInitialized -> Call ::Update() on the layer.
8.  Cast to GraphicsLayer.
9.  Get the Graphics Collection.

I assumed I would see all the Features within the Layer as graphics; I don't (its count = 0).

NOTE:  If the LocalFeatureLayer is created and given to a map it will have a valid Graphics Collection.

Does anyone see another way around this??

-Mike
0 Kudos
12 Replies
JustinHunter
Regular Contributor
It worked! Sorry about the confusion, I thought I read SelectionOnly as the mode to use.

When I call .Update() inside my FeatureLayer_Initialized my next breakpoint brings me into my layer_UpdateCompleted! When I look at my (sender as FeatureLayer).Graphics.Count I get me 1000, which is the limit that my server will return to me.

Thanks so much for this. :)!
0 Kudos
MikeShaw
New Contributor
Thanks Mike.  Working like a charm.

If anyone wants my code I can push it out ...

-Mike
0 Kudos
PatricTrollope
Emerging Contributor
Confirmed, works perfectly!

Thank you all for your time and assistance, it is very much appreciated.

Regards,
Patric
0 Kudos