Select to view content in your preferred language

MarkerSymbol to change size according to Zoom Level

2446
3
12-08-2010 11:39 AM
amishakhera
New Contributor
Hello,

I believe that we can have the angle of the marker symbol as some dependency property in Silverlight 4 as illustrated in this post http://blogs.esri.com/Dev/blogs/silverlightwpf/.

Similarly I want the size of the marker symbol as a dependency property which would change whenever zoom level of the map changes. Basically I want the marker symbol size to be less at zoom out level and it should increase as we are zooming in.

How should I proceed for the above given requirement? I am using ArcGIS API for Silverlight/WPF version 2.1 and Silverlight 4 on VS 2010.

Following is the code being used for my present marker symbol :

           
<esriSymbols:MarkerSymbol x:Name="MarkerSymbol_EOL">
                <esriSymbols:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Canvas>
                  
                            <Ellipse Height="12" Width="12" Canvas.Left="-7" Canvas.Top="-7" RenderTransformOrigin="0.5,0.5" x:Name="gradientellipse" Stroke="#C96FE0FD" IsHitTestVisible="False">
                                <Ellipse.RenderTransform>
                                    <ScaleTransform />
                                </Ellipse.RenderTransform>
                                <Ellipse.Fill>
                                    <RadialGradientBrush>
                                       
                                        <GradientStop Color="#FF6FE0FD" Offset="0.35"/>
                                        <GradientStop Color="White" Offset="1"/>
                                    </RadialGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                        </Canvas>
                    </ControlTemplate>
                </esriSymbols:MarkerSymbol.ControlTemplate>

            </esriSymbols:MarkerSymbol>
0 Kudos
3 Replies
BjørnarSundsbø
Deactivated User
I haven't tried this, and it is just an idea from the top of my head. For the width and height of the Ellipse, you could try to create a converter as using the following binding:
<esriSymbols:MarkerSymbol x:Name="MarkerSymbol_EOL">
                <esriSymbols:MarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Canvas>               
                            <Ellipse Height="{Binding Path=Resolution, ElementName=MyMap}, Converter={StaticResource SizeConverter}, ConverterParameter={Binding ElementName=MyMap}"
...


SizeConverter takes in the resolution of the map which will trigger an update when the zoomlevel changes. As a parameter, pass in the map.

Inside of the converter, try to use the maps MinimumResolution, MaximumResolution and Resolution to calculate the actual width and height for the ellipse. You probably might want to add some logic for levels so the symbol won't disappear or cover the whole map when zooming too far in or out.

Bjørnar Sundsbø
0 Kudos
wangzhifang
Frequent Contributor
Why not just simply use a symbol in ElementLayer?
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ElementLayer
0 Kudos
amishakhera
New Contributor
@bsundsbo : Thanks for the quick reply. Even I was thinking on these lines and this is what I needed to know. I am pretty new to silverlight and Arcgis Silverlight API... Can you please provide a sample code to create converter or any project which is using these kind of dynamic binding. I would really appreciate the help.

@diligentpig : Thanks for your reply. Actually I am using lot of marker symbol properties, so according to my requirement I can not do it via element layer, so looking for a more efficient way.
0 Kudos