2016-12-30 67 views
0

我将图像添加到MapControl中,但在缩放地图时,图像的大小正在变化。C#MapControl如何防止图像在缩放时改变大小?

 Image img = new Image(); 
     img.Source = new BitmapImage(new Uri("ms-appx:///Assets/weii.png")); 
     img.Opacity = 0.1; 
     img.Stretch = Stretch.None; 


     MapControl.SetNormalizedAnchorPoint(img, new Point(0.5, 0.5)); 
     MapControl.SetLocation(img, new Geopoint(new BasicGeoposition() { Latitude = 51.236852, Longitude = 22.548944 })); 

     mapa.Children.Add(img); 

我怎样才能让图像不改变大小?

回答

1

我相信你会看到一个错误的锚点可能导致的错觉。当锚点位置不正确时,图钉图像会出现漂移,并可能看起来像可能稍微改变大小。您当前的代码将图像固定在图像的中心。看看这篇博客文章,了解如何正确锚点图钉:https://rbrundritt.wordpress.com/2014/10/02/correcting-anchoring-pushpins-to-the-map/

+0

这不是视错觉。在放大和缩小地图时,图像真的改变了大小。图像被锚定到由MapControl.Location指定的MapControl上的点。 – Hartnack

+0

我刚刚在Windows Phone上运行了您的代码,并且它工作得很好。图像不会更改大小。你是在仿真器还是在实际设备上运行你的代码? 另外值得注意的是,你应该瞄准Win10而不是WP8.1,因为WP8.1的市场份额正在缩小,因为那些仍在Windows Phone 8.1上的用户正在安装更新。 – rbrundritt

+0

我是与Win10设备上的runnig代码。 [链接](http://imgur.com/a/37Bdl)这里是它对我的作用。 – Hartnack

相关问题