Ejemplo n.º 1
0
        private void _map_OnRightClick(object sender, MapPointLatLon pos)
        {
            Waypoint click = new Waypoint(new OsmNode(1, pos.Lat, pos.Lon));

            Waypoint nearest = _streets.Waypoints.Values.OrderBy(w => w.DistanceTo(click)).First();

            if (_clickIndex == 0)
            {
                if (_currentPath != null)
                {
                    _map.RemovePath(_currentPath);
                    _currentPath = null;
                }

                _startPoint = nearest;
                _endPoint   = null;

                _clickIndex = 1;
            }
            else if (_clickIndex == 1)
            {
                _endPoint = nearest;

                var p = _streets.FindPath(_startPoint, _endPoint);
                if (p != null)
                {
                    _currentPath = _map.AddPath(_routeLayer, p.Waypoints.Select(wp => new MapPointLatLon(wp.Lat, wp.Lon)), Color.Red);
                }

                _clickIndex = 0;
            }
        }