Select to view content in your preferred language

Graphic scaling

899
5
10-29-2010 03:32 PM
AlexAgranov
Emerging Contributor
How do I scale a graphic appropriate to the current extent? Bigger as I zoom in, smaller as I zoom out?
0 Kudos
5 Replies
OrenGal
Regular Contributor
You can try something like this:

  private void m_map_ExtentChanged(object sender, ExtentEventArgs e)
        {
            Envelope pNewEnv = e.NewExtent;
               
            double pWidthScreen = m_map.Width * f_glob._pixel_size;
            double pWidthMap = m_map.Extent.Width;
            double pScale = pWidthMap / pWidthScreen;

            foreach (Graphic pGraphic in pGraphicLayer)
            {
                PictureMarkerSymbol pSymbol = (PictureMarkerSymbol)pGraphic.Symbol;
                pSymbol.Width = your number/pScale;
                pSymbol.Height = your number/pScale;
            }
        }
0 Kudos
JenniferNery
Esri Regular Contributor
You can apply ScaleTransform to the symbol template. Please look at the samples here: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#CustomSymbols
0 Kudos
AlexAgranov
Emerging Contributor
You can try something like this:

  private void m_map_ExtentChanged(object sender, ExtentEventArgs e)
        {
            Envelope pNewEnv = e.NewExtent;
               
            double pWidthScreen = m_map.Width * f_glob._pixel_size;
            double pWidthMap = m_map.Extent.Width;
            double pScale = pWidthMap / pWidthScreen;

            foreach (Graphic pGraphic in pGraphicLayer)
            {
                PictureMarkerSymbol pSymbol = (PictureMarkerSymbol)pGraphic.Symbol;
                pSymbol.Width = your number/pScale;
                pSymbol.Height = your number/pScale;
            }
        }


2 questions:

1. What is  f_glob supposed to be?
2. What is "your number"?
0 Kudos
dotMorten_esri
Esri Notable Contributor
A simpler approach is probably just to use the ElementLayer: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ElementLayer
Notice the red box (put whatever you like there instead of the red box)
0 Kudos
OrenGal
Regular Contributor
2 questions:

1. What is  f_glob supposed to be?
2. What is "your number"?


Sorry. Copied Pasted from an old app.
pixel_size and your number are constants.
pixel size is your monitor pixel size in the unit of the map (example : 0.000263 in meters)
your number is a the size of the symbol.
0 Kudos