SimpleMarkerSymbol doesn't relatively scale based on zoom

1377
3
10-09-2012 02:04 AM
AlistairDorman-Smith
New Contributor
Hello

I have some code below:
  var symbol = new esri.symbol.SimpleMarkerSymbol();
  symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE;
  symbol.setSize(8);
  symbol.setColor(new dojo.Color([0,0,0,0.6]));

But I've found that the setSize method is very basic and it doesn't scale based on the zoom. i.e. when you zoom out, I would expect the symbols to get smaller, but retain their relative size.

My goal is to have different size symbols based on the value it's representing. However without them scaling based on zoom this isn't achievable.

Apologies if there is a very simple answer but I haven't been able to find it!

Hope you can help.
0 Kudos
3 Replies
__Rich_
Occasional Contributor III
The unit of size for the symbol is the pixel, - you've set your symbol size to 8 pixels and that's what it will always be, irrespective of map scale 8 pixels on your display is still 8 pixels, if you see what I mean.

I think the behaviour you're hoping to replicate is the "Scale symbols when a reference scale is set" option that's found in ArcMap?  (of course if you were getting ArcGIS Server to render an image of the layer then you'd be able to use this!)

I don't think (but could be wrong!) there's out-the-box support for what you're trying to do i.e. size client-side symbols based on scale but perhaps you could write some code to do it, maybe hook into something like the map's onExtentChange event and re-render your symbols based on the new scale...presumably at a risk to performance etc!

edit: Ah, hold on, just re-read your post, you don't just want to size the symbols based on scale, you also want to size them based on the value of an attribute, you could potentially achieve the latter (and therefore maybe your whole aim!) with a renderer, have a read:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/inside_renderers.htm

...and then have a look at the samples:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/book_overviews/overview_renderers.htm...
0 Kudos
AlistairDorman-Smith
New Contributor
Thanks for your reply.

The Class Break Renderers look interesting and the most suited for my needs, but I was assuming (perhaps incorrectly) the same effect could be created by adding some maths to the setSize method when looking through my data with a bit of logic in my code.

That said, the really big problem that renderers don't appear to help with is relative sizing when zooming!

If I were to create an 80 pixel symbol when zoomed in to a specific part of the UK, that's fine - big  but fine. However when I start to zoom out, the single symbol soon covers the entire UK! I could redraw them when the extent changes but that seems like it would be a lot of code to write (particularly to keep the logic of the value-based sizes).

So although the renderers could help with one of my requirements, sadly it looks like the zoom issue could be a deal-breaker for me with this approach.
0 Kudos
__Rich_
Occasional Contributor III
Re. 'Maths' - I don't think it'd be that much code, it's just that it (potentially) could be executed many times, adversely affecting performance...also you'd have to get the calculations just right otherwise I suppose you could end up with a situation where zooming out your marker becomes so small that nobody can see it etc.

Just a side note, the Desktop help says:

Setting a reference scale will cause your fill symbols to become larger as you zoom in from the reference scale and to shrink as you zoom out. It's important to recognize this behavior because it is not typically what interactive map users want in their online, multiscale basemaps. When designing and working with interactive and Web maps, it's likely that you will want to disable this reference scale behavior.


What type of service are you serving your data with? Or is it all purely client-side?
0 Kudos