Bing 地图 silverlight 控制图钉缩放问题
基本上我的问题是我已经改编了在这里找到的一段代码
这正是我想要的它要做的就是根据地图的缩放级别缩放一些图钉图像。唯一的问题是我已经调整了此代码以与 bing 地图 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 元素的不同方式有关。有关细节也非常有用。谢谢你!
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:
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);
becomes something like
layer.AddChild(new Pin
{
ImageSource = new BitmapImage(new Uri("pin.png", UriKind.Relative)),
MapInstance = map
}, new Location(-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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将您自己的固定大小位图图像添加到地图中,而不是使用图钉类
try adding your own fixed size bitmapimage to the map rather than using the pushpin class
感谢earthware的回复,我成功解决了我的问题。只需直接添加图像(不涉及图钉类),为其添加固定大小并相应地设置缩放的 CenterX 和 CenterY 属性即可。代码示例如下:
Thanks to earthware's response I managed to solve my problem. It is just a matter of adding the image direclty (no pushpin class involved), adding a fixed size to it and setting the CenterX and CenterY properties of the scaling accordingly. Code sample follows:
下面的示例展示了如何使用图钉对象(而不是图像对象)通过地图的 ZoomLevel 自动缩放图钉并将它们保持在正确的位置。所有这一切都需要自定义 IValueConverter、ScaleTransform 和一些数据绑定的帮助。
http: //pietschsoft.com/post/2010/06/04/Resizing-and-Auto-Scaling-Pushpin-in-Bing-Maps-Silverlight.aspx
Here's an example that shows how to Auto Scale Pushpins with the Map's ZoomLevel using the Pushpin object (instead of an Image object) and keeps them in the correct location. All with a little help from a custom IValueConverter, ScaleTransform and a little Data Binding.
http://pietschsoft.com/post/2010/06/04/Resizing-and-Auto-Scaling-Pushpin-in-Bing-Maps-Silverlight.aspx