How to position images (without using pinpoint)

2 posts, 0 answers
  1. Russell Aisbitt
    Russell Aisbitt avatar
    8 posts
    Member since:
    Oct 2009

    Posted 12 Apr 2010 Link to this post

    Not a question this time. I just thought I might post this in case it is of help to others playing with the RadMap.
     
    This is how to add images to the radmap map with a bit more control over the image than is available by simply adding a bitmap using the pinpoint method.

            // Set provider
                    BingMapProvider provider = new BingMapProvider(MapMode.Aerial, true, "YOUR CODE GOES HERE");
                    provider.IsTileCachingEnabled = true;
                    mWindow.radmap.Provider = provider;

            // Create information layer
                    iLayer = new InformationLayer();
                    iLayer.MapControl = mWindow.radmap;
                    mWindow.radmap.Items.Add(iLayer);

            // Create a new image object and add it to bing map.
                    Uri uri = new Uri(@"" + imageName, UriKind.Relative);

                    BitmapImage bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = uri;
                    bitmap.EndInit();

                    Image image = new Image();
                    image.Source = bitmap;
                    image.Opacity = 0.85;
                    image.Width = imageWidth;
                    image.Height = imageHeight;
                    image.Stretch = Stretch.UniformToFill;
                    image.SnapsToDevicePixels = true;
                    image.Name = Name;

            // When added to map, centre image over Lat/Long rather than use upper left corner for placement
                    image.VerticalAlignment = VerticalAlignment.Center;
                    image.HorizontalAlignment = HorizontalAlignment.Center;

            // Add the image to the map
                    MapLayer.SetLocation(image, new Location(dLatitude, dLongitude));
                    iLayer.Items.Add(image);

  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 14 Apr 2010 Link to this post

    Hi Russell,

    Yes, this is one of the standard ways how it can be done. The RadMap supports 2 ways to align FrameworkElement around the location.
    The first one (you've described it) is using VerticalAlignment and HorizontalAlignment.
    HorizontalAlignment.Right (default) - the element is located to the right of the location.
    HorizontalAlignment.Left - the element is shifted to the left of the location.
    HorizontalAlignment.Center - the element is centered over the location.

    VerticalAlignment.Bottom (default) - the element is located at the bottom of the location.
    VerticalAlignment.Top - the element is shifted to the top of the location.
    VerticalAlignment.Center - the element is centered over the location.

    The second approach is using of the HotSpot definition. The HotSpot can be defined for the whole element as well as for any children inside. Hot spot is a position inside or outside the element which is bound to the geographical location  specified for the framework element. You can see how it can be implemented in our RadMap demo:
    http://demos.telerik.com/silverlight/#Map/HotSpot

    All the best,
    Andrey Murzov
    the Telerik team


    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top