setSelectionSymbol doesn't work first time...

2580
6
07-23-2013 04:00 PM
KenMorefield
Occasional Contributor
Does anyone know why setSelectionSymbol doesn't work after the first select, but any subsequent select will result in the selection symbol working?

Ken
0 Kudos
6 Replies
KenMorefield
Occasional Contributor
Nobody else has seen this problem?  Basically, I have two dijit.form.filteringselects that when the first select is chosen, it "filters" the second select.  Once the second select is chosen, the value is passed to a querytask which selects a feature and then the map is zoomed to that resulting feature.  The zooming works fine, but the selected feature does not show up (setSelectionSymbol) does not get set.  But if you go up and select a new value (kicking off the whole process again), then the setSelectionSymbol works... Any ideas?

Thanks,
Ken
0 Kudos
GregKnight
Occasional Contributor
Ken,

While this certainly wont help you, I am having a similar problem.  Selection symbols for feature layers dont seem to work at all.

Perhaps there is a real problem here? 

Greg

        var eqOutFields = [equipmentLayerIdFieldName, equipmentLayerTitleFieldName];

        // prepare equipment layer
        var equipmentLayer = new esri.layers.FeatureLayer( gisMapControl.getEquipmentLayerUrl(), {
            id: "equipmentLayer",
            index: 20,
            infoTemplate: eqTemplate,
            mode: esri.layers.FeatureLayer.MODE_ONDEMAND, // MODE_SNAPSHOT
            opacity: 1.0,
            outFields: eqOutFields
        });

        // add equipment layer
        map.addLayer(equipmentLayer);
        me.setEquipmentLayer(equipmentLayer);
        console.log('Equipment layer added...');

        // set equipment layer selection symbol
        var eqSelectionSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 12, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0]), 1.0), new dojo.Color([0,0,0,0.35]));
        equipmentLayer.setSelectionSymbol(eqSelectionSymbol);
0 Kudos
DianaBenedict
Occasional Contributor III
Ken and Greg

I am successfully using selection symbols with FeatureLayers and Pop windows.  At some point early in developing the code I would see weird issues come up but it seemed to me like it was attributed to my code and not the functionality of FeatureLayer selection symbol.

Below are a couple of functions that I use to return the selection symbol based on two "hypothetical" scenerios  .. selection and reselection (cyan and yellow):

  this.GetFillSelectionSymbol = function (selectionType) {
    selectionType = selectionType ? selectionType : "selection";
    var selectionColor = null;
    if (selectionType === "selection") {
      //cyan
      selectionColor = new dojo.Color([0, 255, 255, 1.0]);
    } else {
      //yellow
      selectionColor = new dojo.Color([255, 255, 0, 1.0]);
    }

    var fillSymbol = new esri.symbol.SimpleFillSymbol();
    fillSymbol.setStyle(esri.symbol.SimpleFillSymbol.STYLE_NULL);
    fillSymbol.setColor(selectionColor);
    fillSymbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, selectionColor, 4));
    return fillSymbol;
  }

  this.GetMarkerSelectionSymbol = function (selectionType, markerSize) {
    markerSize = markerSize ? markerSize : 25;
    selectionType = selectionType ? selectionType : "selection";
    var markerSymbol = new esri.symbol.SimpleMarkerSymbol();
    markerSymbol.setStyle = esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE;
    markerSymbol.setSize(markerSize);
    markerSymbol.setOutline(null);

    if (selectionType === "selection") {
      markerSymbol.setColor(new dojo.Color([0, 255, 255, 0.5]));
    } else {

      markerSymbol.setColor(new dojo.Color([255, 255, 0, 0.5]));
    }
    return markerSymbol;
  }

0 Kudos
GregKnight
Occasional Contributor
Thanks Diana.  I will give your code a look-see and hopefully Ill have better luck tomorrow.

Thanks again...
0 Kudos
MaudGillespie
Occasional Contributor
This thread has been inactive for a while, but I'm experiencing the exact same problem.  setSelectionSymbol doesn't work for the first query, but then works fine in all subsequent queries.  I've experimented with different initial view extents, and there seems to be correlation, but I can't figure it out.  That is, if my initial extents is large area, like the entire state, a single, selected parcel will not show the symbol.  However, if I set my initial extents to be already zoomed into a parcel then query, it will render.

I have read that rendering of features in feature layers have something to do with the scale level, but I can't be sure.

Anybody have experience in resolving this?

Steve
0 Kudos
SteveLettau
New Contributor
The issue had a couple items associated with it.   First off, the layer I was selecting features on was not visible at the scale of the map I was starting with, and I determined that if I zoomed into a scale that turned my layer on, it worked.

However, a larger issue it uncovered is related to the generalization of features.  The shape of the selection varied based on the scale of the map, that is, if I was zoomed in closely when I started the selection process, the feature shape was more accurate.  If I started the operation zoomed out a bit further, the selection shape was generalized.

I'm working around this by first querying for the feature using a QueryTask, then zooming to the results geometry.  Then I perform a second operation to select the feature.  It works every time now.  Not sure this is a great solution but it works.

Steve
0 Kudos