Selected symbol not changing color

927
2
Jump to solution
09-19-2016 11:24 AM
KarstenRank
Occasional Contributor III

Hi there,

I want to change the selected symbols depending on the geometry of the feature layer. My code looks like that:

switch (geoType) {
case "esriGeometryPoint":
selectionSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20);
break;

case "esriGeometryPolygon":
layer.selectionSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255, 120, 0]), 2), new Color([255, 255, 0, 0.5]));
break;

case "esriGeometryPolyline":
layer.selectionSymbol = new CartographicLineSymbol(CartographicLineSymbol.STYLE_SOLID, new Color([255,255,255,1]), 2);

}

layer.setSelectionSymbol(selectionSymbol);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The marker symbol for point geometry changes, the others get transparent?

Where is the error?

Thank you 

Karsten

Reply
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor

For the point case, you use

selectionSymbol = new ...‍‍

but the polyline and polygon cases, you use

layer.selectionSymbol = new

You have to use

selectionSymbol = new

for these cases since "layer.selectionSymbol" is not the same as "selectionSymbol". Otherwise, you're creating a new property on the "layer" variable instead of setting a new value for the "selectionSymbol" variable. Since "selectionSymbol" is not being set in those two cases, a null value will be set in the setSelectionSymbol method at the end of your code fragment.

View solution in original post

2 Replies
KenBuja
MVP Honored Contributor

For the point case, you use

selectionSymbol = new ...‍‍

but the polyline and polygon cases, you use

layer.selectionSymbol = new

You have to use

selectionSymbol = new

for these cases since "layer.selectionSymbol" is not the same as "selectionSymbol". Otherwise, you're creating a new property on the "layer" variable instead of setting a new value for the "selectionSymbol" variable. Since "selectionSymbol" is not being set in those two cases, a null value will be set in the setSelectionSymbol method at the end of your code fragment.

View solution in original post

KarstenRank
Occasional Contributor III

Hello Ken,

thank you for the help. Now it works!

Reply
0 Kudos