Answered by:
Bing maps silverlight control pushpin scaling problems.

Question
-
Basically my problem is that i've adapted a piece of code found here
which does exactly what I want it to do, that is scale some pushpin images according to the map's zoom level. The only problem is that I've adapted this code to run with the bing maps silverlight control (not virtual earth like in the original example) and now the images scale correclty, but they are repositioned and only reach the desired position when my zoom level is maximum. Any idea why? Help will be greatly appreciated :)
Modified code below:
//Sydney layer.AddChild(new Pin { ImageSource = new BitmapImage(new Uri("pin.png" , UriKind.Relative)), MapInstance = map }, new Location(-33.86643, 151.2062), PositionMethod.Center);
becomes something likelayer.AddChild(new Pin { ImageSource = new BitmapImage(new Uri("pin.png" , UriKind.Relative)), MapInstance = map }, newLocation(-33.92485, 18.43883), PositionOrigin.BottomCenter);
I am assuming it has something to do with a different way in which bing maps anchors its UIelements. Details on that are also very userful. Thank you!
- Edited by Team Flux Tuesday, April 6, 2010 1:25 PM
Tuesday, April 6, 2010 12:40 PM
Answers
-
Figured it out. It is just a matter of adding the image direclty, adding a fixed size to it and setting the centerx and centery properties of the scaling accordingly. Code sample follows:
image.Source = new BitmapImage(new Uri("pin.png", UriKind.Relative)); image.Stretch = System.Windows.Media.Stretch.None; image.Height = 152; image.Width = 116; layer.AddChild(image, new Location(-33.86643, 151.2062), PositionOrigin.BottomCenter); image.RenderTransform = scaleTr; scaleTr.CenterX = image.Width / 2; //image is alligned bottom center (see above) scaleTr.CenterY = image.Height;
- Marked as answer by Ricky_BrundrittModerator Tuesday, April 6, 2010 11:58 PM
Tuesday, April 6, 2010 2:18 PM
All replies
-
The address not display.
博客:http://beniao.cnblogs.com MSN:beniao@live.cnTuesday, April 6, 2010 12:53 PM -
Figured it out. It is just a matter of adding the image direclty, adding a fixed size to it and setting the centerx and centery properties of the scaling accordingly. Code sample follows:
image.Source = new BitmapImage(new Uri("pin.png", UriKind.Relative)); image.Stretch = System.Windows.Media.Stretch.None; image.Height = 152; image.Width = 116; layer.AddChild(image, new Location(-33.86643, 151.2062), PositionOrigin.BottomCenter); image.RenderTransform = scaleTr; scaleTr.CenterX = image.Width / 2; //image is alligned bottom center (see above) scaleTr.CenterY = image.Height;
- Marked as answer by Ricky_BrundrittModerator Tuesday, April 6, 2010 11:58 PM
Tuesday, April 6, 2010 2:18 PM -
Here's an example of how to Auto Scale Pushpins according to the Map's ZoomLevel that actually uses the Pushpin control, instead of creating your own custom "pushpin" image control.
Microsoft MVP - Windows Live Platform
Blog: http://pietschsoft.com | Web.Maps.VE - ASP.NET AJAX Virtual Earth Server ControlFriday, June 4, 2010 6:07 AM