Update features with StreamLayer

315
1
11-04-2013 04:06 AM
ChristineBrunner
New Contributor III
I'm using the StreamLayer to show data from GeoEventProcessor on my map. Like in the sample I use a FeatureCollection to initialize the layer:

layerDefinition = {
        "geometryType": "esriGeometryPoint",
        "fields": [{
            name: "OBJECTID",
            type: "esriFieldTypeOID"
          },
          {
            name: "id",
            type: "esriFieldTypeDouble"
          },
          {
            name: "name",
            type: "esriFieldTypeString"
          }
        ]};
var featureCollection = {
            "layerDefinition": null,
            "featureSet": {
              "features": [],
              "geometryType": "esriGeometryPoint"}
            };
featureCollection.layerDefinition = layerDefinition;
var layer = new StreamLayer(featureCollection, {
              socketUrl: "<url>",
              purgeOptions : { displayCount: 1000 },
          infoTemplate : new esri.InfoTemplate("${name}")
            });


At first glance everything is ok. The data is shown on the map and by clicking on a feature, you can see the attributes. However for each event a new feature is added to the map by the StreamLayer. This is ok for sources like Twitter messages. But I want to show moving features (trains) in my application. Is it possible to mark one of the fields of the FeatureCollection as ID field, so features are updated?

Thanks, Christine
0 Kudos
1 Reply
CarisaSmith
New Contributor III
If you still haven't found a solution for this, I had the same issue and received a response back from ESRI with a work around until they incorporate the TrackId field to replace old messages coming thru the StreamLayer WebSocket.  I'll attach their example.
0 Kudos