OpenStreetMap coloring the map tiles by state, zip code polygons from C# VS 2013 WPF desktop application RRS feed

  • Question

  • I would like to create a map from C# VS2013 WPF desktop application (not web application) with OpenStreetMap on win7.

    This a colored map with US states colorized differently.

    This can be shown in the attachment below.

    I am new to WPF and handle the map tiles from XAML.

    It seems to be very hard to find state or zip code borders from the map tiles and do coloring on them. I know that adding a colored map tile layer on the map may be working. But I would like to see some code examples to follow so that I can implement my design based on it.

    Are there some open source C# code that have done the similar things ?

    Any help would be appreciated. 

    an example colorized map

    • Edited by usa2015usa Saturday, December 5, 2015 4:48 PM
    Saturday, December 5, 2015 4:47 PM


All replies

  • Color coding states, zip codes and other well known boundaries can be done with Bing Maps. You first need to get the boundary data. In Bing Maps this is available through the GeoData API: The following code samples shows how to use the GeoData API in a WPF app: Note that this does a bit more work and combines the boundaries together which it doesn't sound like you need to do. Instead, modify the GetZipcodeBoundary method to return a MapPolygon. Then you can easily just add this to the Bing Maps WPF control:

    Note this process has nothing to do with map tiles. Also, this has nothing to do with OpenStreetMaps.

    Monday, December 7, 2015 5:25 PM
  • Thanks,

    I can get lat/lon for a zip code polygon.

    Now, how to add the polygon to Bing Map WPF control so that the polygon can be shown on the map with an indicated color such as red

    Are there some examples about how to do this ?

    Also, I hope that the added polygon is a map layer not an user interface element because I may need to add thousands of colorized polygons.

    Performance is important for me.

    Any help would be appreciated.

    • Edited by usa2015usa Wednesday, December 9, 2015 8:02 PM
    Wednesday, December 9, 2015 8:02 PM
  • I can add the zip code area as MapPolygon

    But, when the number if zip codes are increased, such as 30000,  the WPF application was frozen.

    I think I have added too much UIElements to the map.

                foreach(MapPolygon p in mapPolygonList)

    Are there ways to add them efficiently ?


    Thursday, December 10, 2015 7:33 PM