This is a migrated thread and some comments may be shown as answers.

Better zoomlevel precision and adding labels to shapes

1 Answer 68 Views
Map
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 06 Dec 2010, 02:33 PM
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);
 
    this.LabelLayer.Items.Add(lblCounty);

If possible, I really need some answers this week.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Dec 2010, 08:26 AM
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
Tags
Map
Asked by
James
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or