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
Solved! Go to Solution.
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.
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.
Hello Ken,
thank you for the help. Now it works!