The code below is copied from "HowDoISample" but does not draw between two coordinates.
Not : files are attached only change file extension zip to rar
static RectangleShape turkeyShape = new RectangleShape(2888708.1725842, 5172748.5338836, 4927301.9983436, 4265512.2928742);
private MapManager _mapManager;
private static RoutingEngine routingEngine;
private static RoutingSource RoutingSourceForShortest;
private static RoutingSource RoutingSourceForFastest;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Server.MapPath("RoutingData/Kadikoy_polyline.shp"));
RoutingSourceForShortest = new RtgRoutingSource(Server.MapPath("RoutingData/Kadikoy_polyline.rtg"));
routingEngine = new RoutingEngine(RoutingSourceForShortest, featureSource);
routingEngine.GeographyUnit = GeographyUnit.Meter;
RenderMap();
FindPath();
}
}
private void RenderMap()
{
Map1.MapUnit = GeographyUnit.Meter;
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = turkeyShape;// new RectangleShape(-10884474.4001792, 3542175.58734002, -10877416.7249544, 3537139.84069311);
// Map1.RestrictedExtent = turkeyShape;
PointShape point = Map1.CurrentExtent.GetCenterPoint();
Map1.ZoomTo(point, Map1.ClientZoomLevelScales[6]);
GoogleOverlay google = new GoogleOverlay("Google Map");
google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUri"]);
google.GoogleMapType = GoogleMapType.Normal;
Map1.BackgroundOverlay = google;
RoutingLayer routingLayer = new RoutingLayer();
routingLayer.StartPoint = new PointShape(double.Parse("29.0439132097907", CultureInfo.InvariantCulture), double.Parse("40.9922252527833", CultureInfo.InvariantCulture));
routingLayer.EndPoint = new PointShape(double.Parse("29.0481970808968", CultureInfo.InvariantCulture), double.Parse("40.9782405733082", CultureInfo.InvariantCulture));
Map1.DynamicOverlay.Layers.Add("RoutingLayer", routingLayer);
InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();
routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
routingExtentLayer.InternalFeatures.Add(new Feature(turkeyShape));
Map1.DynamicOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);
}
private void FindPath()
{
RoutingLayer routingLayer = (RoutingLayer)Map1.DynamicOverlay.Layers["RoutingLayer"];
routingLayer.Routes.Clear();
RoutingResult routingResult = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint);
routingLayer.Routes.Add(routingResult.Route);
Map1.DynamicOverlay.Redraw();
}
004_003_002_001_Routing_Data.zip (479 KB)