c.brunneresri-de-esridist

Update features with StreamLayer

Discussion created by c.brunneresri-de-esridist Employee on Nov 4, 2013
Latest reply on May 8, 2014 by carisasmith
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

Outcomes