Select to view content in your preferred language

Highlight trail of a moving equipment

861
3
06-15-2010 11:19 AM
RavinderGairola
Emerging Contributor
I am getting trucks geo location from RSS feed refreshing every 30 seconds.
I have created a feature layer where I am displaying current location of trucks and their trail (using latestObservationRenderer, observationRenderer, observationAger, trackRenderer). Now since there are so many trucks passing through same path it???s really difficult to track path of a selected truck.

I would like to add a feature in my widget where when user select a particular truck then the truck symbol and its track gets highlighted on the map and kept highlighted as truck moving until user select other truck or hit clear button.
When user hit clear button the track and truck display goes to default display.  When user select new truck then its path get highlight and previous truck path become normal.

I am not sure if there is some property or function I can use or have to write lot of custom code.

I will really appreciate any help on this.
Tags (2)
0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
You could set the latestObservationRenderer and observationRenderer to instances of UniqueValueRenderer, where the UniqueValueRenderer has a defaultSymbol used by most observations and then a UniqueValueInfo with the symbol to use for a particular observation.

For the latestObservationRenderer, you could set the UniqueValueInfo.attribute to be the object id field name and then set the corresponding value in the UniqueValueInfo. For the observationRenderer's UniqueValueRenderer, you'd need to set the attribute to some kind of track id field that is common to all the features in a track.

Once you have the renderer set up, you can make the FeatureLayer redraw by resetting it on itself.
    featureLayer.renderer = featureLayer.renderer;

Another option is to create a custom Renderer class that can return the symbol you want based on your own logic.
0 Kudos
RavinderGairola
Emerging Contributor
Following is the code I tried as per your suggestion

var latestObservation:UniqueValueRenderer = new UniqueValueRenderer();
latestObservation.attribute = "title";
var uniqueValueInfos:Array = [];
uniqueValueInfos.push(new UniqueValueInfo(truckHeadingEastSym, event.currentTarget.infoData.title));
latestObservation.infos = uniqueValueInfos;
    
var observation:UniqueValueRenderer = new UniqueValueRenderer();
latestObservation.attribute = "title";
var uniqueValueInfos1:Array = [];
uniqueValueInfos1.push(new UniqueValueInfo(new SimpleLineSymbol("solid",0xCCCC99), event.currentTarget.infoData.title));
observation.infos = uniqueValueInfos1;
        
truckRendere.latestObservationRenderer = latestObservation;
truckRendere.observationRenderer = observation;
    
haulTruckFeed.truckFeatureLayer.renderer = truckRendere;
haulTruckFeed.truckFeatureLayer = haulTruckFeed.truckFeatureLayer;   


Can you please verify if my understanding is correct or not. When this code executes it will remove all other trucks from the layer though I want others as well.
0 Kudos
DasaPaddock
Esri Regular Contributor
You need to set the UniqueValueRenderer's defaultSymbol to be used by the other observations. If a renderer returns null, the graphic is not drawn.
0 Kudos