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

InformationLayer centering png image on location?

2 Answers 73 Views
Map
This is a migrated thread and some comments may be shown as answers.
Damian Slee
Top achievements
Rank 1
Damian Slee asked on 08 Apr 2010, 03:26 PM
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 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 08 Apr 2010, 04:19 PM
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.
0
Damian Slee
Top achievements
Rank 1
answered on 09 Apr 2010, 02:40 AM
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);


 

 

 

Tags
Map
Asked by
Damian Slee
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Damian Slee
Top achievements
Rank 1
Share this question
or