Better zoomlevel precision and adding labels to shapes

2 posts, 0 answers
  1. James
    James avatar
    30 posts
    Member since:
    Aug 2008

    Posted 06 Dec 2010 Link to this post

    ZoomLevel only accepts and int and the difference between two levels is pretty large (e.g. 7 and 8 for the State shapefiles in the demos. Is there a way I can fake that in code somehow, I need just a little more zoom, not the huge zoom that going from 7 to 8 gives me?

    Also, when adding labels to counties on a state map, the Location of GeographicalBounds.Center is often not desirable since it sometimes is not even within the same county as a result of oddly shaped counties. How can I tweak the Location placement when doing MapLayer.SetLocation(lblCounty, shape.GeographicalBounds.Center)?

    Lastly, thanks for giving me this code a few weeks ago, but I have one more problem with it. The HotSpot makes my mouseover tooltip not work when the mouse is over the HotSpot - very confusing behavior for a user. How can I fix that? I've tried a few things, but can't seem to get it.

    The code:
    foreach (MapShape shape in this.InformationLayer.Items)
        string name = (string)shape.ExtendedData.GetValue("NAME");
        TextBlock lblCounty = new TextBlock();
        //lblCounty.Text = name.Substring(0, 2);
        lblCounty.Text = name;
        lblCounty.FontFamily = new FontFamily("Arial");
        lblCounty.FontSize = 9.5;
        if (name.ToLower().Equals("perry"))
            RotateTransform rotateTransform;
            double newRotation = -20.00;
            rotateTransform = new RotateTransform(newRotation);
            lblCounty.RenderTransform = rotateTransform;
        MapLayer.SetLocation(lblCounty, shape.GeographicalBounds.Center);
        MapLayer.SetHotSpot(lblCounty, hotSpot);

    If possible, I really need some answers this week.

    Thanks in advance.
  2. Andrey
    Andrey avatar
    1681 posts

    Posted 09 Dec 2010 Link to this post

    Hi James,

    The RadMap control supports integer zoom levels only. There is not way to set fractional zoom level.

    Calculation of the so called "geometric center" or "centroid" of polygon is not an easy mathematical task. There are several algorithms for it. You can find them in the internet. Unfortunately RadMap currently doesn't provide this functionality and it does not seem to be a trivial one. I will make sure it is reconsidered when discussing our future plans, but I am afraid no certain time frame can be given at the moment.

    If your map shape has a tooltip, then you can simple assign it to the TextBlock:

    object shapeTooltip = ToolTipService.GetToolTip(shape);
    if (shapeTooltip != null)
       ToolTipService.SetToolTip(lblCounty, shapeTooltip);

    Best wishes,
    Andrey Murzov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
Back to Top