コード例 #1
0
        private void mapItemButton_Click(object sender, RoutedEventArgs e)
        {
            var mapItemButton = sender as Button;
            PointOfCustomRoute currMapItem = mapItemButton?.DataContext as PointOfCustomRoute;

            if (currMapItem != null)
            {
                int ind = MyMapVM.PointList.IndexOf(currMapItem);
                MyMapVM.PointList.RemoveAt(ind);
                if (ind == 0)
                {
                    myMap.MapElements.Remove(_lastPolyline);
                    MyMapVM.PointList.Clear();
                    MyMapVM.IsRouting = false;
                    return;
                }
                DrawPolyline();
                if (ind != MyMapVM.PointList.Count)
                {
                    double delta = MyMapVM.PointList[ind].CurrentLenght - MyMapVM.PointList[ind - 1].CurrentLenght -
                                   PointOfCustomRoute.GetDistance(MyMapVM.PointList[ind], MyMapVM.PointList[ind - 1]);
                    for (int i = ind; i < MyMapVM.PointList.Count; i++)
                    {
                        MyMapVM.PointList[i].CurrentLenght -= delta;
                    }
                }
            }
        }
コード例 #2
0
        private void myMap_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            if (MyMapVM.IsRouting)
            {
                Debug.WriteLine(String.Format(args.Location.Position.Latitude + " " + args.Location.Position.Longitude));
                PointOfCustomRoute currPoint = new PointOfCustomRoute()
                {
                    Location = args.Location,
                    NormalizedAnchorPoint = new Point(0.5, 0.93)
                };
                if (MyMapVM.PointList.Count != 0)
                {
                    currPoint.CurrentLenght = MyMapVM.PointList.Last().CurrentLenght +
                                              PointOfCustomRoute.GetDistance(MyMapVM.PointList.Last(), currPoint);
                }
                MyMapVM.PointList.Add(currPoint);

                DrawPolyline();
            }
        }