ArcGIS API for JavaScript: StreamLayer: geometryDefinintion

3019
3
10-16-2014 04:18 PM
TodStevens
New Contributor II

Has anyone been able to make the geometryDefinition work with the StreamLayer sample?

Has anyone been able to make the setDefinitionExpression work with the StreamLayer sample?

 

This has no effect:

  streamLayer.setDefinitionExpression("RouteID < 50");

 

 

 

I set an extent and pass it in but all features still draw on the map?

 

var layer = new StreamLayer(featureCollection, {

              socketUrl: txtWsUrl.value,

              purgeOptions: { displayCount: 500 },

             geometryDefinition : myextent,

Tags (2)
0 Kudos
3 Replies
TodStevens
New Contributor II

The following shows that the expression is not getting set for some reason...

  console.log(streamLayer.defaultDefinitionExpression);

  console.log(streamLayer.getDefinitionExpression());

  streamLayer.setDefinitionExpression("RouteID < 50"); // only our jurisdictions: use '' single quotes around literals

  console.log("New..");

  console.log(streamLayer.getDefinitionExpression());

Result (console.log)

undefined           streamlayer3.html:433

undefined           streamlayer3.html:434

New..                  streamlayer3.html:437

undefined

0 Kudos
CarisaSmith
New Contributor III

Did you ever get this answered or working?  I'm having the same problem and discovered that the DefinitionExpression works fine if the StreamLayer is created with an ESRI service URL, but if the StreamLayer is created using a FeatureCollection object... the setDefinitionExpression does not work and does not filter any of the data streaming thru.  The definition expression does seem to be set now though.

0 Kudos
CarisaSmith
New Contributor III

ESRI JavaScript API doesn't support setDefinitionExpression, if you create the StreamLayer w a FeatureCollection object.  The setDefinitionExpression is applied server-side and not client-side, so no way of filtering the data.  For any future issues w this, you'll have to add a filter of your own in the graphic-add event.  This is from ESRI...

  1. streamLayer.on("graphic-add", function(evt){

              var g = evt.graphic;

              if(g.attributes.RouteID < 50){

                streamLayer.remove(g);

              }

            });

0 Kudos