【发布时间】:2015-03-26 10:06:16
【问题描述】:
我正在尝试创建一个跟踪我当前位置的应用程序。这是我的代码:
private Image currentLocationPin;
private async void CurrentLocationChanged(Geolocator sender, PositionChangedEventArgs args)
{
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
mapControl.Children.Remove(currentLocationPin);
currentLocationPin = new Image() { Source = new BitmapImage(new Uri(smallIconURI)) };
var currentGeo = new Geopoint(new BasicGeoposition
{
Latitude = args.Position.Coordinate.Point.Position.Latitude,
Longitude = args.Position.Coordinate.Point.Position.Longitude
});
MapControl.SetNormalizedAnchorPoint(currentLocationPin, new Point(0.5, 1));
MapControl.SetLocation(currentLocationPin, currentGeo);
mapControl.Children.Add(currentLocationPin);
currentLocationPin.Tapped += ChildObj_Tapped;
mapControl.LandmarksVisible = false;
mapControl.TrafficFlowVisible = false;
mapControl.PedestrianFeaturesVisible = false;
currentGeopoint = currentGeo;
});
}
当我当前的位置改变时,这个函数会被调用。它工作得很好,但是这个问题。因为我删除了前一个引脚然后添加了一个新引脚,所以当我在地图上看到它时,每 2 个引脚之间有一个延迟。我尝试使用 MapIcon,但它也不起作用。我试图不删除别针并仅更新其位置,但在旧别针旁边会有一个新别针。 谢谢。
【问题讨论】:
-
你找到解决办法了吗?
标签: c# xaml dictionary windows-phone-8.1