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

Transform shapes works with state maps, but not the US shapefile??

2 Answers 95 Views
Map
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 07 Dec 2010, 03:57 PM
private void StateLayerReaderReadCompleted(object sender, ReadShapesCompletedEventArgs eventArgs)
{
    ScaleTransform scaleMap;
    scaleMap = new ScaleTransform(1.2, 1.2);
 
    TranslateTransform moveMap;
    moveMap = new TranslateTransform(-50, 0);
 
    TransformGroup tg = new TransformGroup();
    tg.Children.Add(moveMap);
    tg.Children.Add(scaleMap);
 
    RadMap1.RenderTransform = tg;
 
    if (eventArgs.Error != null)
        return;
 
    this.LabelLayer.Items.Clear();
 
    HotSpot hotSpot = new HotSpot();
    hotSpot.X = 0.5;
    hotSpot.Y = 0.5;
 
    foreach (MapShape shape in this.InformationLayer.Items)
    {
        string name = (string)shape.ExtendedData.GetValue("STATE_NAME");
        TextBlock lblState = new TextBlock();
        lblState.Text = name;
        lblState.FontFamily = new FontFamily("Trebuchet MS");
        lblState.FontSize = 9.5;
        lblState.FontWeight = FontWeight.FromOpenTypeWeight(750);
 
        if (
            (
                name.ToLower().Equals("alaska")
            )
           )
        {
            //ScaleTransform scaleAK;
            //scaleAK = new ScaleTransform(-4.5, -4.5);
 
            //TranslateTransform moveAK;
            //moveAK = new TranslateTransform(100, -200);
 
            //TransformGroup tgAK = new TransformGroup();
            //tgAK.Children.Add(moveAK);
            //tgAK.Children.Add(scaleAK);
 
            //shape.RenderTransform = scaleAK;
            TranslateTransform moveTransform;
            moveTransform = new TranslateTransform(800, 200);
            shape.RenderTransform = moveTransform;
        }

This worked for me on a map of Pennsylvania (I could move a county shape this way), but not for Alaska and Hawaii on the us ESRI shapefile. I want to scale down Alaska and move is closer so that its visible and scale up Hawaii and move it as well. The transforms seem to not work at all in this case, but, like I said, worked fine on a PA county.

2 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 07 Dec 2010, 04:28 PM
As I look at it more closely, it seems that I cannot Transform the shapes within the shapefile. Is that correct or is there a way to achieve that?
I can transform the whole RadMap and the labels I add to a layer I added to the map with no problem, i.e. scale the map up a little works fine, move my labels around depending on the county or state name, etc., but I can't seem to effect the shapes at all.
0
Andrey
Telerik team
answered on 10 Dec 2010, 09:45 AM
Hi James,

You must not use any transformations (Rotate, Scale or Translate) with map shape objects. These objects have precise geographical coordinates and size. Using of any transformation over it brakes all calculations. The resulting behavior is unpredictable. The same is true for the RadMap control itself. But you can move the MapShape object to another location. You can use MoveTo() method of the map shape for this purposes. For example:

Location location = new Location(-50, 100);
shape.MoveTo(location);

Keep in mind that the visual appearance of the moved shape can be changed (scaled) according to the Mercator projection.

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
James
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or