本文介绍了Bing Maps和WP Toolkit图钉问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在地图控件上放置图钉时出现问题。每当我开始捏缩放时,图钉开始移动。

你可以在下面的截图中看到这一点(我正在放大):

I'm having an issue with placing pushpins on my map control. Every time I start pinching to zoom the pushpins start shifting.
You can see this in the following screenshots (I'm zooming in):


这是我用来生成引脚的C#代码

This is the C# code I use to generate the pins

foreach (var item in context.NearbyParkings)
            {
                //Assemble pushpin
                MapOverlay pushOverlay = new MapOverlay();
                var newPushPin = new Pushpin();
                StackPanel pinContent = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal };
                TextBlock tb = new TextBlock
                {
                    Text = item.name
                };

                Image icon = new Image
                {
                    Width = 25,
                    Height = 25,
                    Margin = new Thickness(0, 0, 5, 0)
                };

                Uri uri = new Uri("/Images/Icon.png", UriKind.Relative);
                BitmapImage imgSource = new BitmapImage(uri);
                icon.Source = imgSource;


                if (item.carambla)
                {
                    pinContent.Children.Add(icon);
                }
                pinContent.Children.Add(tb);

                //Add content to pushpin
                newPushPin.Content = pinContent;

                //Set colour
                if (item.hasFreeSpots)
                {
                    newPushPin.Background = new SolidColorBrush(Color.FromArgb(200, 16, 191, 3));
                }
                else
                {
                    newPushPin.Background = new SolidColorBrush(Color.FromArgb(200, 221, 68, 0));
                }

                if (!item.hasAvailabilityInfo)
                {
                    newPushPin.Background = new SolidColorBrush(Color.FromArgb(200, 2, 132, 220));
                }


                //Set event
                newPushPin.Tap += pushPinTapEvent;
                newPushPin.Tag = item;
                newPushPin.GeoCoordinate = new GeoCoordinate(item.latitude, item.longitude);

                //Place layer
                pushOverlay.Content = newPushPin;
                pushOverlay.GeoCoordinate = new GeoCoordinate(item.latitude, item.longitude);
                pushOverlay.PositionOrigin = new Point(1, 0.5);


                //Add layer to map
                MapLayer newMapLayer = new MapLayer();
                newMapLayer.Add(pushOverlay);
                mapMain.Layers.Add(newMapLayer);
            }

这是我的XAML

<maps:Map x:Name="mapMain" LandmarksEnabled="True" Margin="0,0,0,30" Height="411" ViewChanged="mapMain_ViewChanged" CenterChanged="mapMain_CenterChanged"/>


如何修复转换问题?

How can I fix the shifting issue?

推荐答案

http://stackoverflow.com/questions/18447106/setanchor-for-mapoverlay

http://stackoverflow.com/questions/18447106/setanchor-for-mapoverlay


这篇关于Bing Maps和WP Toolkit图钉问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 04:36