Select to view content in your preferred language

Renderer : creating from json ignores width and height

1274
6
09-29-2013 11:33 PM
MichalGasparovic
Occasional Contributor
Hi,

can anyone explain why is renderer ignoring my width and height settings for the picture marker symbols ?

if I create the renderer like this:
new SimpleRenderer(new PictureMarkerSymbol({"url":"./graphics/rm/renderer/boatRamp.png","height":24,"width":24,"type":"esriPMS"}))

the renderer ends up with the symbol properties of :

height: 32
size: 16
type: "picturemarkersymbol"
url: "./graphics/rm/renderer/boatRamp.png"
width: 32
xoffset: 0
yoffset: 0


When I create the renderer like this:
new SimpleRenderer(new PictureMarkerSymbol('./graphics/rm/renderer/boatRamp.png', 24, 24))
then it works as expected.

Any ideas?
Thank you
0 Kudos
6 Replies
ManishkumarPatel
Deactivated User
You can try the below code, if it works:

  var yourSymbol = new esri.symbol.PictureMarkerSymbol({
        "angle":0,
        "xoffset":0,
        "yoffset":10,
        "type":"esriPMS",
        "url":"http://static.arcgis.com/images/Symbols/Transportation/GreenSquareDaymark.png",
        "contentType":"image/png",
        "width":24,
        "height":24
      });

Good luck!!!
0 Kudos
MichalGasparovic
Occasional Contributor
nope.. that didn't help. Specifying the content type didn't make any difference. I'm getting desperate to be honest.. there must be something I'm missing, I went according the doco, when I realized that the images are pixelated that's how I've noticed it. Please note, that the image size and the symbol size I'm trying to set are exactly equal... just renderer sets it differently 😞
0 Kudos
ManishkumarPatel
Deactivated User
nope.. that didn't help. Specifying the content type didn't make any difference. I'm getting desperate to be honest.. there must be something I'm missing, I went according the doco, when I realized that the images are pixelated that's how I've noticed it. Please note, that the image size and the symbol size I'm trying to set are exactly equal... just renderer sets it differently 😞


check this if it helps:

http://jsfiddle.net/patelmanya/9byGw/3/

I tried setting multiple size for the symbol. Let me know if this is what you looking for.

Thanks and Good luck!!
0 Kudos
MichalGasparovic
Occasional Contributor
check this if it helps:

http://jsfiddle.net/patelmanya/9byGw/3/

I tried setting multiple size for the symbol. Let me know if this is what you looking for.

Thanks and Good luck!!


thanks for that jsfiddle mate, I've modified to create the PictureMarkerSymbol from json, and have a look yourself that the images are larger (right-click and inspect the element, you'll see the width is 120px!)

Any ideas why the picture marker symbol from json is ignoring the width/height ? There seems to be some kind of multiplication by 1.33333 constant ??

I've also noticed that toJson() on the symbol is not returning the same width/height properties. To me this is a bug.

http://jsfiddle.net/9byGw/4/

M
0 Kudos
MichalGasparovic
Occasional Contributor
by our local esri support team I was pointer to the doco where it says that once it's declared using json, the widths and height are to be set in POINTS rather then pixels. kuddos to them.
0 Kudos
ManishkumarPatel
Deactivated User
thanks for that jsfiddle mate, I've modified to create the PictureMarkerSymbol from json, and have a look yourself that the images are larger (right-click and inspect the element, you'll see the width is 120px!)

Any ideas why the picture marker symbol from json is ignoring the width/height ? There seems to be some kind of multiplication by 1.33333 constant ??

I've also noticed that toJson() on the symbol is not returning the same width/height properties. To me this is a bug.

http://jsfiddle.net/9byGw/4/

M


Hi Michal,

I spend sometime testing with different symbols and found the same behavior you mentioned,

for instance if we are using the below symbol:

  var infoSymbol = new esri.symbol.PictureMarkerSymbol({
        url: "http://developers.arcgis.com/en/javascript/samples/map_topo_graphics/images/info.png",
        width: 10,
        height: 10
    });

the output in the results frame after inspecting the symbol element is as below:

<image fill-opacity="0" stroke="none" stroke-opacity="0" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" x="447.3333333333333" y="221.33333333333334" width="13.333333333333333" height="13.333333333333333" preserveAspectRatio="none" xlink:href="http://developers.arcgis.com/en/javascript/samples/map_topo_graphics/images/info.png" transform="matrix(1.00000000,0.00000000,0.00000000,1.00000000,0.00000000,0.00000000)">

I tried to search on the web found a bug similar (not related) to this issue but that is if the source is set before setting this properties:

For your reference: http://support.esri.com/en/bugs/nimbus/TklNMDUzODcy

Also I tried using another symbols and the results are same, the width and height properties seems to be different than specified. Seems like you found a BUG 😮

If you want to have a look check this fiddle: http://jsfiddle.net/patelmanya/9byGw/10/

You could log a bug for this issue with ESRI.

Thanks,
Manish
0 Kudos