Skip to content

Restoring OpenStreetMapLayer Functionality in ThinkGeo UI

Are you using the ThinkGeo UI OpenStreetMapLayer in your application and experiencing problems with map tiles not loading? This may be due to recent changes on OpenStreetMap’s side in which they are more strictly enforcing their Tile Usage Policy. This policy requires (among other things) that any application consuming tiles from OpenStreetMap’s servers must identify itself with a valid HTTP User-Agent. By default, ThinkGeo’s OpenStreetMapLayer does not specify a User-Agent, but you can (and should) set one yourself.

No matter which edition of ThinkGeo UI you are using, you can specify your own User-Agent on each tile request by handling the OpenStreetMapLayer’s SendingWebRequest event. In the method you set up to handle this event, you’ll have access to the WebRequest object in one of the parameters. Simply cast it as an HttpWebRequest and set the UserAgent property to a custom string that identifies your application. That’s it!

Here’s some sample code you can use. In the block below, we set up a simple map containing an OpenStreetMapLayer. The relevant portion is where we attach the Osm_SendingWebRequest handler to the SendingWebRequest event. In the definition of this handler, we set the User-Agent to “Test Application”.

private void map_Loaded(object sender, RoutedEventArgs e)
    map.MapUnit = GeographyUnit.Meter;
    map.ZoomLevelSet = new OpenStreetMapsZoomLevelSet();            

    LayerOverlay osm = new LayerOverlay();
    osm.MaxExtent = new RectangleShape(-20037508, 20037508, 20037508, -20037508);

    OpenStreetMapLayer layer = new OpenStreetMapLayer();
    layer.SendingWebRequest += Osm_SendingWebRequest;


    map.CurrentExtent = new RectangleShape(-20037508, 20037508, 20037508, -20037508);

private void Osm_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
    (e.WebRequest as HttpWebRequest).UserAgent = "Test Application";

Please note that OpenStreetMap does reserve the right to restrict or block access to their tile server from any User-Agent or originating IP that seems to be using it too heavily, a threshold which is purely at their discretion and unfortunately beyond ThinkGeo’s control.

If you find yourself being limited by OpenStreetMap’s tile usage policy, you may want to consider using ThinkGeo’s own Cloud Maps for your base map instead. Based on OpenStreetMap data and available in both traditional raster tile and lightweight vector tile formats with styling that can be dynamically customized, ThinkGeo’s Cloud Maps can cover all of your base map needs. Get in touch with us at if you have questions about how to migrate from OpenStreetMap to ThinkGeo Cloud Maps, or login to the ThinkGeo Cloud to try them for yourself. If you’re a new user, you’ll automatically be entitled to a free 60-day evaluation.

Let us know in the comments below if this helped you out. If you’re having other issues, feel free to post in the ThinkGeo Community Forums and we’ll be happy to assist you!

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *