Using the Arcgis Javascript API, I create a SimpleMarkerSymbol with the JSON constructor.
Documentation : https://developers.arcgis.com/javascript/jsapi/simplemarkersymbol.html#simplemarkersymbol3
The size and color of the symbol are obtained from GUI elements (color from a palette, size from an input text box).
My code is very simple :
var pointColor = ... //no point in writing this part of the code
var pointSize = symbologyTable.getElementsByClassName("inputSize")[0].value;
console.log("pointSize = ", pointSize);
var pointSymbol = new esri.symbol.SimpleMarkerSymbol(
{
"color" : pointColor,
"size" : pointSize,
"style" : "esriSMSCircle"
}
);
console.log("pointSymbol = ", pointSymbol);
The problem : the symbol size displayed with the second console.log is never consistent with the one obtained from the input text box. For exemple, if I create three points, changing the value in the input text box, the console.log looks like this :
pointSize = 15
pointSymbol = Object{ color=..., size=20, ...}
pointSize = 8
pointSymbol = Object{ color=..., size=10.66666666, ...}
pointSize = 4
pointSymbol = Object{ color=..., size=5.333333333, ...}
For debug purpose, I have tried writing a size value directly in the JSON while creating the pointSymbol variable (tried either "size" : 15
or "size" : "15"
), but the size is always modified in the console.log.
What does work is the setSize(size)
function : If I use pointSymbol.setSize("15")
and then print the pointSymbol, its size is 15.
Any clue why the JSON size definition might not work?
Thank you very much for your help!
EDIT (1) : 2016-01-06 : The same problem occurs with the SimpleLineSymbol https://developers.arcgis.com/javascript/jsapi/simplelinesymbol.html
EDIT (2) : 2016-01-06 : The same problem occurs with the Font and TextSymbol https://developers.arcgis.com/javascript/jsapi/font.html https://developers.arcgis.com/javascript/jsapi/textsymbol.html