Which layer do I choose?

1128
11
10-18-2010 12:55 PM
BjørnarSundsbø
Occasional Contributor
I have an application where I will display dynamic features moving in the map. There might be quite many of them for an area ( <2000, I think). They should move when their position is update. I'm wondering if I should create my own "fake" FeatureService to return the features, or if I should use GraphicsLayer for displaying them.

Any reccomendations?

Bjørnar Sundsbø
0 Kudos
11 Replies
AliMirzabeigi
New Contributor
In addition to the GraphicsLayer you can publish a time-aware FeatureLayer http://help.arcgis.com/en/webapi/silverlight/help/time_aware_layers.htm if there is a time associated with the features in your layer. You can use some out of the box controls like TimeSlider to track your objects on the map. Here you can find some examples:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#TimeFeatureLayer
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#TemporalRendererTracks
0 Kudos
BjørnarSundsbø
Occasional Contributor
Thanks. It's pretty much where I'm headed. Though I do not have ArcGIS server for most of my customers, and the features to display are not there for users who do, I've started to implement my own REST FeatureService to return the data. This seems ideal as then I do not have to maintain ViewModel to feature data integrity, and can just transform the data directly to information the featurelayer can handle (and hope updates to existing features is handeled, not just removing everything, and forgetting the previous state/selection).

My concern is updating the features, and selection. I was thinking of using TimeExtent, and hope I can use it to update the features every second, or whatever is required. I will not have historic data, and it will be real-time (within the configured time delay). And if I can update the features every second, will selection in the map be maintained when an existing object gets a different position or symbol?
0 Kudos
AliMirzabeigi
New Contributor
Selection on the map will be persisted if you change Geometry or Symbology of a given Graphic since it won't change the Graphic's selection state.
0 Kudos
dotMorten_esri
Esri Notable Contributor
I've done this before. Basically I every few seconds request the ID and location of all features that have changed since the last request. I then go through the graphics that matches the returned IDs and update their Geometry property (changing the geometry automatically updates their position on the map). You can even create a little loop that animates X and Y from the old to the new position, to give a sense of "movement".
0 Kudos
BjørnarSundsbø
Occasional Contributor
Morten,

Could you provide some more details?
0 Kudos
dotMorten_esri
Esri Notable Contributor
Not sure exactly what you want. I can't give you details on the entire application (that would take me half the day).
But the gist of it is that I use a QueryTask in a DispatcherTimer that triggers every few seconds and requests all features where TimeStamp>lastRequestTimeStamp in the where clause (there's a timestamp attribute on my features).
I then go through each feature in the GraphicsLayer, check its graphics id and see if I got that ID back from the server. If I did, I'll update it's geometry property.
0 Kudos
BjørnarSundsbø
Occasional Contributor
Some more information: I have a MVVM application, and would like to place some of my ViewModels in the map. I just noticed the ElementLayer. It seems like I could use this to avoid having to introduce and update a Graphic for every item I want to place in the map. Every time I change the geometry, I could use the SetEnvelope property.

I suppose this might be a solution for my post about Styling Graphic.

The question is, how is the performance of ElementLayer compared to a GraphicLayer as this layer contains "heavier" objects.

I assume I would still have the problem I face in Location of PictureMarkerSymbol vs MarkerSymbol.
0 Kudos
JenniferNery
Esri Regular Contributor
I asked around. ElementLayer and GraphicsLayer do not have much difference in performance as far as we know. GraphicsLayer should be sufficient.
0 Kudos
BjørnarSundsbø
Occasional Contributor
So you recommend using GraphisLayer and have a "duplicate" mapping between my ViewModel and a Graphics, instead of placing my ViewModel directly into the ElementLayer and avoid the duplication?
Using ElementLayer might also remove the need to synchronize selection between our ViewModels in list and in the map (ViewModel is selected inside an ItemsControl, and it's corresponding Graphic should be selected). Also, it would also simplify drag and drop between the map and other parts of the application by removing the lookup of the ViewModel based on Graphic. Say a user wishes to drag a vehicle from the map, and drag it to a list of some kind.

I might be arguing my own case here in favor of ElementLayer, though I miss some more documentation in the API about ElementLayer and when to use it (work in progress, I know). I would also like your opinion here.

What can the GraphicsLayer do that the ElementLayer can't?
0 Kudos