Example #1
0
 void mapControl1_MapMouseClick(MapControlEventArgs e)
 {
     if (_router != null)
     {
         if (_point1 == null)
         {
             _point1 = _router.Resolve(Vehicle.Car, e.Position);
         }
         else if (_point2 == null)
         {
             _point2 = _router.Resolve(Vehicle.Car, e.Position);
         }
         else
         {
             _point1 = _point2;
             _point2 = _router.Resolve(Vehicle.Car, e.Position);
         }
         if (_point1 != null && _point2 != null)
         {
             OsmSharpRoute route = _router.Calculate(Vehicle.Car,
                                                     _point1, _point2);
             if (route != null)
             {
                 _routeLayer.Clear();
                 _routeLayer.AddRoute(route);
             }
         }
     }
 }
Example #2
0
 private void MapMarkerClicked(object sender, EventArgs e)
 {
     if (sender is MapMarker)
     {
         lock (_router) {
             MapMarker   marker = sender as MapMarker;
             RouterPoint point  = _router.Resolve(Vehicle.Car, marker.Location);
             if (point != null)
             {
                 if (_previousPoint != null)
                 {
                     _routeLayer.Clear();
                     OsmSharpRoute route = _router.Calculate(Vehicle.Car, _previousPoint, point);
                     if (route != null)
                     {
                         _routeLayer.AddRoute(route);
                     }
                     _routeLayer.Invalidate();
                 }
                 _previousPoint = point;
             }
         }
     }
 }