private void RenderMap() { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1")); winformsMap1.CurrentExtent = new RectangleShape(-97.763384, 30.299707, -97.712382, 30.259309); ShapeFileFeatureLayer austinstreetsLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Austinstreets.shp"); austinstreetsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(GetRoadStyle()); austinstreetsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay austinstreetsOverlay = new LayerOverlay(); austinstreetsOverlay.Layers.Add("AustinstreetsLayer", austinstreetsLayer); winformsMap1.Overlays.Add("AustinstreetsOverlay", austinstreetsOverlay); // The layer for rendering routing result InMemoryFeatureLayer routingLayer = new InMemoryFeatureLayer(); routingLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(100, GeoColor.StandardColors.Purple), 5); routingLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay routingOverlay = new LayerOverlay(); routingOverlay.Layers.Add("RoutingLayer", routingLayer); winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay); // The layer for rendering start and end points InMemoryFeatureLayer stopLayer = new InMemoryFeatureLayer(); stopLayer.Open(); stopLayer.Columns.Add(new FeatureSourceColumn("Order")); stopLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.SimpleColors.LightGreen), new GeoPen(GeoColor.SimpleColors.Black), 12); stopLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Urban1("Order"); stopLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.XOffsetInPixel = -4; stopLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay stopOverlay = new LayerOverlay(); stopOverlay.Layers.Add("StopLayer", stopLayer); winformsMap1.Overlays.Add("StopOverlay", stopOverlay); // Add start and end points to the layer RoutingSource routingSource = new RtgRoutingSource(@"..\..\SampleData\Austinstreets.rtg"); routingSource.Open(); austinstreetsLayer.Open(); Feature startRoad = austinstreetsLayer.FeatureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns); Feature startPoint = new Feature(startRoad.GetShape().GetCenterPoint().GetWellKnownBinary()); startPoint.ColumnValues["Order"] = "1"; stopLayer.InternalFeatures.Add(startPoint); Feature endRoad = austinstreetsLayer.FeatureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns); Feature endPoint = new Feature(endRoad.GetShape().GetCenterPoint().GetWellKnownBinary()); endPoint.ColumnValues["Order"] = "2"; stopLayer.InternalFeatures.Add(endPoint); routingSource.Close(); austinstreetsLayer.Close(); winformsMap1.Refresh(); }
private void btnGetInformation_Click(object sender, EventArgs e) { ShapeFileFeatureLayer dallasStreetsLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "DallasCounty-4326.shp")); dallasStreetsLayer.Open(); RtgRoutingSource routingSource = new RtgRoutingSource(Path.Combine(rootPath, "DallasCounty-4326.rtg")); routingSource.ReadEndPoints = true; routingSource.Open(); RouteSegment road = routingSource.GetRouteSegmentByFeatureId(txtRoadId.Text); // render routeSegment information RenderRoadInformation(dallasStreetsLayer, road); // render adjacent routeSegments information RenderAdjacentRoadsInformation(dallasStreetsLayer, road); dallasStreetsLayer.Close(); routingSource.Close(); winformsMap1.Refresh(new Overlay[] { winformsMap1.Overlays["currentRoadOverlay"], winformsMap1.Overlays["adjacentRoadsOverlay"] }); }