Select to view content in your preferred language

polygon outline setStyle() and setWidth() not working

865
3
Jump to solution
01-21-2014 05:30 PM
BenFousek
Regular Contributor
Polygon outline setStyle() and setWidth() are not updating the graphic in the map but the object is updating. These are the only two that aren't working for all symbol types and settings.

A fiddle to demonstrate.

The functions in question:
updateLineType: function (value, graphic) {   switch (graphic._type) {   case 'polyline':     graphic.symbol.setStyle(value);     break;   case 'polygon':     //what is wrong with setting polygon outline style?????     graphic.symbol.outline.setStyle(value);     break;   }   graphic.getLayer().refresh(); }, updateLineWidth: function (value, graphic) {   switch (graphic._type) {   case 'polyline':     graphic.symbol.setWidth(value);     break;   case 'polygon':     //what is wrong with setting polygon outline width?????     graphic.symbol.outline.setWidth(value);     break;   }   graphic.getLayer().refresh(); },
0 Kudos
1 Solution

Accepted Solutions
RobertoPepato
Occasional Contributor II
Polygon outline setStyle() and setWidth() are not updating the graphic in the map but the object is updating. These are the only two that aren't working for all symbol types and settings.

A fiddle to demonstrate.

The functions in question:
updateLineType: function (value, graphic) {   switch (graphic._type) {   case 'polyline':     graphic.symbol.setStyle(value);     break;   case 'polygon':     //what is wrong with setting polygon outline style?????     graphic.symbol.outline.setStyle(value);     break;   }   graphic.getLayer().refresh(); }, updateLineWidth: function (value, graphic) {   switch (graphic._type) {   case 'polyline':     graphic.symbol.setWidth(value);     break;   case 'polygon':     //what is wrong with setting polygon outline width?????     graphic.symbol.outline.setWidth(value);     break;   }   graphic.getLayer().refresh(); },


You can get the desired effect by reseting the symbol on the polygon graphic.

For example, to turn the polygon outline from solid to dashed you can use:

var symbol = polygon.symbol; symbol.outline.setStyle(SLS.STYLE_DASH); polygon.setSymbol(symbol);


Let me known if it helps.

Roberto Pepato.

View solution in original post

0 Kudos
3 Replies
RobertoPepato
Occasional Contributor II
Polygon outline setStyle() and setWidth() are not updating the graphic in the map but the object is updating. These are the only two that aren't working for all symbol types and settings.

A fiddle to demonstrate.

The functions in question:
updateLineType: function (value, graphic) {   switch (graphic._type) {   case 'polyline':     graphic.symbol.setStyle(value);     break;   case 'polygon':     //what is wrong with setting polygon outline style?????     graphic.symbol.outline.setStyle(value);     break;   }   graphic.getLayer().refresh(); }, updateLineWidth: function (value, graphic) {   switch (graphic._type) {   case 'polyline':     graphic.symbol.setWidth(value);     break;   case 'polygon':     //what is wrong with setting polygon outline width?????     graphic.symbol.outline.setWidth(value);     break;   }   graphic.getLayer().refresh(); },


You can get the desired effect by reseting the symbol on the polygon graphic.

For example, to turn the polygon outline from solid to dashed you can use:

var symbol = polygon.symbol; symbol.outline.setStyle(SLS.STYLE_DASH); polygon.setSymbol(symbol);


Let me known if it helps.

Roberto Pepato.
0 Kudos
BenFousek
Regular Contributor
Thanks Roberto. That works.

It's just curious that all other symbol types and their respective set methods work in that manner but these two don't.
0 Kudos
RobertoPepato
Occasional Contributor II
Thanks Roberto. That works.

It's just curious that all other symbol types and their respective set methods work in that manner but these two don't.


Good point. I don't know how to explain why that works for one kind of geometry but it doesn't work for another. Maybe someone from Esri can clarify this question?
0 Kudos