This example uses OpenStreetMapDataProvider to connect Map Control to the OpenStreetMap service.
IMPORTANT: Specify a valid OSM server name in the
OpenStreetMapDataProvider.TileUriTemplateproperty. For instance, you can set your own tile server, use a public OSM server or choose alternative OSM servers. For more information, refer to the following article: Tile Usage Policy.
Follow the steps below to display the OpenStreetMap geodata in the Map Control:
-
Use the
ServicePointManager.SecurityProtocolproperty to specify the network security protocol before theInitializeComponentmethod call. -
Create a
MapControlobject. Set theMapControl.Dockproperty to the DockStyle.Fill value to fit the Map Control to the form. Call the Add method to add the Map Control to the form's control collection. -
Create
ImageLayerand use theMapControl.Layers.Addmethod to add this layer to the map. -
Create an
OpenStreetMapDataProviderobject and assign it to theImageLayer.DataProviderproperty. Specify theOpenStreetMapDataProvider.TileUriTemplateproperty to load data from an OSM server. Our example contains a sample template string that does not connect to an existing OSM server. -
Handle the
OpenStreetMapDataProvider.WebRequestevent and specify thee.UserAgentande.Refererproperties in the event handler.
- How to: Use the OpenStreetMap Search Service Via the Map Control
- How to: Use the OpenStreetMap Geocode Service Via the Map Control
(you will be redirected to DevExpress.com to submit your response)