【问题标题】:windows 8 bing maps pushpins moving when zoom in/outWindows 8 bing 地图图钉在放大/缩小时移动
【发布时间】:2013-09-25 14:02:37
【问题描述】:

我正在使用 Bing 地图为 Windows 8 商店开发地图,我在地图中绘制了多个自动取款机和分支,而不是使用图钉,而是使用我创建的控件并将它们放在相应的位置。 问题是,当缩放级别为(例如)13 时,引脚离它们的实际位置有点远,而当我放大引脚时,引脚开始移动到实际位置。

有没有人知道我应该怎么做才能将大头针固定在他们的位置,尽管实际的地图缩放级别?

这是我的 atms 绘制代码:

AgenciesMarkers Aginfo = new AgenciesMarkers(); 
Aginfo.Agclass = atm; 
Aginfo.ImageType = new BitmapImage(new Uri(typeSource, UriKind.Absolute)); 
Aginfo.Height = 65; 
Aginfo.Tapped += new Windows.UI.Xaml.Input.TappedEventHandler(AGMarker_click); Aginfo.SetValue(Canvas.ZIndexProperty, 4); 
MapLayer.SetPosition(Aginfo, (new Location(atm.Latitude, atm.Longitude))); mapLayer.Children.Add(Aginfo); mapLayer.Margin = new Thickness(25, 0, 0, 0);

使用图钉会发生同样的事情。

【问题讨论】:

  • 我认为您需要向我们展示一些代码。你为什么用自己的别针?您可以使用标准图钉重现问题吗?
  • 这是我的 atms 抽奖代码:AgenciesMarkers Aginfo = new AgenciesMarkers(); Aginfo.Agclass = atm; Aginfo.ImageType = new BitmapImage(new Uri(typeSource, UriKind.Absolute)); Aginfo.Height = 65; Aginfo.Tapped += new Windows.UI.Xaml.Input.TappedEventHandler(AGMarker_click); Aginfo.SetValue(Canvas.ZIndexProperty, 4); MapLayer.SetPosition(Aginfo, (new Location(atm.Latitude, atm.Longitude))); mapLayer.Children.Add(Aginfo); mapLayer.Margin = new Thickness(25, 0, 0, 0);
  • 我尝试使用自定义图钉但发生同样的事情,图钉移动:S
  • 请编辑您的问题,而不是在 cmets 中发帖!!

标签: c# windows-8 windows-runtime winrt-xaml bing-maps


【解决方案1】:

问题在于,默认情况下,自定义图钉/用户控件的位置使得位置与控件的左上角对齐。如果您不采取任何措施来解决此问题,您将在放大/缩小时看到图钉漂移到该位置或从该位置漂移。解决此问题的一种简单方法是在您的用户控件上添加负边距,以便它将控件与地图上的位置对齐。例如,如果您想将用户控件置于位置的中心,则设置边距,使其 x 值等于 -width of control/2,y 值等于 -height of control/2。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-17
  • 1970-01-01
  • 1970-01-01
  • 2012-08-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多