windowsforms-17904-controls-and-libraries-map-control-examples-gis-data-using-all-gis-providers-how-to-implement-a-route-calculator-using-gis-providers.md
This example demonstrates how to create a calculating routes application using GIS services.
Follow the steps below.
Add an ImageLayer object to the MapControl.Layers collection and assign an instance of the BingMapDataProvider class to the ImageLayer.DataProvider property. Specify the valid Bing key using the BingMapDataProvider.BingKey property.
Add an InformationLayer object to the MapControl.Layers collection and assign an instance of the BingSearchDataProvider to the InformationLayer.DataProvider property. Set the LayerBase.Name property of the layer to SearchLayer.
Add an InformationLayer object to the MapControl.Layers collection and assign an instance of the BingGeocodeDataProvider to the InformationLayer.DataProvider property. Set the LayerBase.Name property of the layer to GeocodeLayer.
Add an InformationLayer object to the MapControl.Layers collection and assign an instance of the BingRouteDataProvider to the InformationLayer.DataProvider property. Set the LayerBase.Name property of the layer to RouteLayer.
For each information layers’ data provider, specify the valid Bing key using the BingMapDataProviderBase.BingKey property and set the InformationDataProviderBase.GenerateLayerItems property value to false.
Create a helper, which allows you to convert MapPushpin objects to RouteWaypoint and store the route using a MapPolyline object.
Prepare properties and members of the form class as follows.
Handle BingSearchDataProvider.SearchCompleted, BingGeocodeDataProvider.LocationInformationReceived and BingRouteDataProvider.RouteCalculated events.
Handle the MapControl.MapItemClick event to add data to the helper.
See Also