InformationLayer centering png image on location?

3 posts, 0 answers
  1. Damian Slee
    Damian Slee avatar
    26 posts
    Member since:
    Nov 2009

    Posted 08 Apr 2010 Link to this post

    I have an information layer of points, where i am using different png images to represent the point.

    However the location point that is set appears to be the top left of the image.   So when zoomed out, it appears to be significantly in a different location.  Do you know how to offset the set lat/long location so that the center point of the image is being used?

    I am forcing the image to be 64x64.   Is there some way to set the margin to -32,-32 to offset the image?   or any other ideas?

                BitmapImage bitmapImage= new BitmapImage();  
                bitmapImage.SetSource(new MemoryStream((Byte[])imageData));  
                var image = new Image();  
                image.Source = bitmapImage;  
                image.Width = 64;  
                image.Height = 64;  
                image.Stretch = Stretch.Uniform;  
     
    // todo: lat long needs to reference center of image.  
    MapLayer.SetLocation(image, new Location(latitude, longitude));  
     



  2. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 08 Apr 2010 Link to this post

    Hello Damian,

    You can check this online map example here: http://demos.telerik.com/silverlight/#Map/HotSpot that might help you to achieve the desired appearance.


    Greetings,
    Bart.
  3. DevCraft banner
  4. Damian Slee
    Damian Slee avatar
    26 posts
    Member since:
    Nov 2009

    Posted 08 Apr 2010 Link to this post

    hmm, i had another look at that hotspot code.   Personally i don't like having to create another element and having to come up with a dynamic element name to associate the hotspot object with it.

    i explored setting the margin idea a bit more, and it was a lot simpler than i realized.  this did the trick, moving it up and left 32 pixels.

    image.Margin = new Thickness(-32, -32, 0, 0);


     

     

     

Back to Top