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

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

    Posted 07 Dec 2010 Link to this post

    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. James
    James avatar
    30 posts
    Member since:
    Aug 2008

    Posted 07 Dec 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 10 Dec 2010 Link to this post

    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
Back to Top