Select to view content in your preferred language

How to base symbol size on zoom in graphics layer

798
4
12-13-2010 05:15 AM
JasonThiel
Emerging Contributor
I may be overlooking something but here goes.  I have a graphics layer that i want to show smaller symbols when map is zoomed out past 1:10000000, medium symbol from 5000000-10000000, and large symbol when < 5000000.

I used the following code in my <renderer> of the graphics layer but it doesn't seem to work.
mainMap is the name of my map, the symbols are defined in declarations.

<esri:ClassBreaksRenderer attribute="{mainMap.scale}">
<esri:ClassBreakInfo maxValue="10000000" symbol="{smallSym}"/>
<esri:ClassBreakInfo maxValue="10000000"
  minValue="5000000"
              symbol="{mediumSym}"/>
<esri:ClassBreakInfo minValue="10000000" symbol="{largeSym}"/>
</esri:ClassBreaksRenderer>
Tags (2)
0 Kudos
4 Replies
JasonThiel
Emerging Contributor
I think that I made a fundamental mistake.  The ClassBreaksRenderer breaks up the data based on data in the layer itself.  So trucks get a truck symbol, cars get a car symbol, bicycles get a bicycle symbol for example.  Breaks are based on layer data.

It looks like I will need to create 3 Graphics layers and use min/max Scale to determine which to use.
0 Kudos
DasaPaddock
Esri Regular Contributor
A couple of other options are:

1. Create a custom renderer by extending the Renderer base class and overwriting the getSymbol() function.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/renderers/Renderer.html

2. Listen for extentChange events on the Map and update the symbology based on the Map's current scale.
0 Kudos
JasonThiel
Emerging Contributor
Thanks Dasa.  I'll probably roll w/ option 2.  With regards to option 1, I wasn't aware that it was possible or encouraged to extend the API.  Are there instructions for doing so?  Is that all java code?  What do you do, make your updates and somehow generate a new .swc file?
Bear with me, i'm new to both Flex and Esri!
0 Kudos
DasaPaddock
Esri Regular Contributor
Many of the classes are designed to be extensible. You can create your own layers, symbols, renderers, clusterers, tasks, etc. There's two samples of custom layers under "Extend API" at:
http://help.arcgis.com/en/webapi/flex/samples/index.html

The code is written in ActionScript and it can just go into your own src tree.
0 Kudos