【问题标题】:Bing maps silverlight control pushpin scaling problems必应地图silverlight控制图钉缩放问题
【发布时间】:2010-04-05 23:08:24
【问题描述】:

基本上我的问题是我已经修改了这里找到的一段代码

http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/62e70670-f306-4bb7-8684-549979af91c1

这正是我想要做的,即根据地图的缩放级别缩放一些图钉图像。唯一的问题是我已经调整此代码以使用 bing maps silverlight 控件(不是原始示例中的虚拟地球)运行,现在图像缩放正确,但是它们被重新定位并且仅在我的缩放级别时到达所需位置是最大值。知道为什么吗?非常感谢您的帮助:)

修改后的代码如下:

var layer = new MapLayer();
map.AddChild(layer);

//Sydney
layer.AddChild(new Pin
{
    ImageSource = new BitmapImage(new Uri("pin.png", UriKind.Relative)),
    MapInstance = map
}, new Location(-33.86643, 151.2062), PositionMethod.Center);

变成类似

layer.AddChild(new Pin
{
    ImageSource = new BitmapImage(new Uri("pin.png", UriKind.Relative)),
    MapInstance = map
}, new Location(-33.92485, 18.43883), PositionOrigin.BottomCenter);

我假设它与 bing 地图锚定其 UI 元素的不同方式有关。这方面的细节也非常有用。谢谢!

【问题讨论】:

    标签: image silverlight bing-maps scaling


    【解决方案1】:

    尝试将您自己的固定大小的位图图像添加到地图中,而不是使用图钉类

    【讨论】:

    • 是的,工作,抱歉之前的帖子。只需为转换设置 FIXED 大小并相应地设置 centerx 和 centery 属性。谢谢土器:)
    【解决方案2】:

    感谢earthware 的回复,我设法解决了我的问题。只需添加图像直接(不涉及图钉类),为其添加固定大小并相应地设置缩放的 CenterX 和 CenterY 属性。代码示例如下:

    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;
    

    【讨论】:

      【解决方案3】:

      这是一个示例,展示了如何使用图钉对象(而不是图像对象)使用地图的 ZoomLevel 自动缩放图钉并将它们保持在正确的位置。借助自定义 IValueConverter、ScaleTransform 和一点点数据绑定,这一切都得到了帮助。

      http://pietschsoft.com/post/2010/06/04/Resizing-and-Auto-Scaling-Pushpin-in-Bing-Maps-Silverlight.aspx

      【讨论】:

        猜你喜欢
        • 2011-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多