Ok, I think I understand what you want to do with the POIs. Once the route is generated from start point to end point, you want to plot on the map, let's say, all the gas stations on that route, the gas stations being in a shapefile. To do that I would do a spatial query on the gas station shapefile using the MultiLineShape from the result of the route. I get the gas stations within a certain distance (tolerance) from the route. I chose 100 meters. The result is a collection of Features and I use an InMemoryFeatureLayer to display separetly (in red in my example). (I use a fictional shapefile of gas stations for this illustration). See the screen shot below:
You can see below the code I used:
// Set the Map Unit and current extent
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow);
// Defines a new layer to render the Austin streets
ShapeFileFeatureLayer StreetLayer = new ShapeFileFeatureLayer(@"..\..\Data\Routing\austinstreets.shp");
StreetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad3;
StreetLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Fename", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Black);
StreetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//defines layer for gas stations
ShapeFileFeatureLayer gasStationLayer = new ShapeFileFeatureLayer(@"..\..\Data\Routing\gasstations.shp");
gasStationLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleSquareStyle(GeoColor.StandardColors.Gray, 12);
gasStationLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay StreetOverlay = new LayerOverlay();
StreetOverlay.Layers.Add("AustinStreetsLayer", StreetLayer);
StreetOverlay.Layers.Add("AustinGasStationLayer", gasStationLayer);
winformsMap1.Overlays.Add("AustinStreetOverlay", StreetOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-97.7532,30.3012,-97.7244,30.2802);
// Define a Routing layer to render the route and stops
RoutingLayer routingLayer = new RoutingLayer();
StreetLayer.Open();
Feature feature1 = StreetLayer.FeatureSource.GetFeatureById("5156", ReturningColumnsType.NoColumns);
Feature feature2 = StreetLayer.FeatureSource.GetFeatureById("8334", ReturningColumnsType.NoColumns);
routingLayer.StartPoint = feature1.GetShape().GetCenterPoint();
routingLayer.EndPoint = feature2.GetShape().GetCenterPoint();
StreetLayer.Close();
LayerOverlay routingOverlay = new LayerOverlay();
routingOverlay.Layers.Add("RoutingLayer", routingLayer);
winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);
RtgRoutingSource rtgRoutingSource = new RtgRoutingSource(@"..\..\Data\Routing\austinstreets.rtg");
RoutingEngine routingEngine = new RoutingEngine(rtgRoutingSource, StreetLayer.FeatureSource);
//InMemoryFeatureLayer for the gas stations on the route (within tolerance)
InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleSquareStyle(GeoColor.StandardColors.OrangeRed, 12);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
StreetOverlay.Layers.Add("SelectedAustinGasStationLayer", inMemoryFeatureLayer);
winformsMap1.Overlays["RoutingOverlay"].Lock.EnterWriteLock();
try
{
routingLayer.Routes.Clear();
MultilineShape routeMultiLineShape = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint).Route;
routingLayer.Routes.Add(routeMultiLineShape);
gasStationLayer.Open();
Collection<Feature> features = gasStationLayer.QueryTools.GetFeaturesWithinDistanceOf(routeMultiLineShape, winformsMap1.MapUnit, DistanceUnit.Meter,
100, ReturningColumnsType.NoColumns);
gasStationLayer.Close();
inMemoryFeatureLayer.Open();
inMemoryFeatureLayer.EditTools.BeginTransaction();
foreach (Feature feature in features)
{
inMemoryFeatureLayer.EditTools.Add(feature);
}
inMemoryFeatureLayer.EditTools.CommitTransaction();
inMemoryFeatureLayer.Close();
}
finally
{
winformsMap1.Overlays["RoutingOverlay"].Lock.ExitWriteLock();
}
winformsMap1.Refresh();
For your last question, let me think about that and I will give you an answer later.