Offline mapping in Windows applications using C#

Imagine a windows desktop computer without internet access that should have the ability to show maps and perform spatial operations(routing, navigation, searching etc), this would require offline mapping application.

Creating an offline mapping solution for windows application is rare and should be avoided. I say, should be, because there are alternatives to developing an offline mapping solution from the scratch. Having said that, there are some possible ways for doing it. Few things to consider are:


Data in GIS applications is of type Vector or Raster. We will be dealing with Vector data in this article. (See Vector vs Raster data in GIS)

One of the starting point is to collect offline data.

  1. You can ask TeleAtlas, NAVTEQ to provide offline data. This will involve licencing fee and NDA. This option could cost a lot
  2. The other options is to use, Download its data and then work with it.

The other thing to consider is the data format. There are number of formats available to work in GIS applications. You can either use a proprietary one, or Shapefile format which is ESRI standard.

Application Development

After selecting data, the next step is to plan for application development. There should be three major steps involved in development of a mapping application.

  • Reading Data
  • Rendering data (geometries)
  • Optimization

First step starts with writing code to read/access data from offline source. This could be a ShapeFile or data stored in Spatial database like PostGIS, Spatialite etc. The approach should be to read data and store in appropriate objects for point, line and polygons.

Once the data is read into objects, the next step is rendering that data on screen, This involves converting geographical coordinates to 2D or 3D map projections on screen. Here is an excellent code project article about it: Writing GIS and Mapping Software for .NET. After transformation of data, the transformed objects are converted to geometry objects and placed on WinForm or WPF window. This might involve a bit of reading about GDI, DirectX, OpenGL or a simpler version of System.Drawing in WinForm or geometry drawing in WPF.

Later comes the optimization part. Map data is usually huge and consists of millions of geometries for a city/metropolis. The optimization in reading and more importantly rendering usually requires lots of work.


There has to be a layering technique involved and then how to show a limited number of geometries. Take an example of google maps, When you are viewing google maps at country level, you can only see city names, city/state/province boundaries, major roads etc, but it doesn’t show street level details. But as soon you start zooming in, one can see the details getting higher and higher. A similar approach could be used in displaying offline maps.

  • Layers for City names (major Point of interest) (Points)
  • Layer for Country/City polygon (Polygon)
  • Layer for major road networks (Line strings)
  • Layer for intercity highways (Line strings)
  • Layer for street level roads (Line strings)
  • Point of interest at street level (Points)

Once the data is setup in these layers, the application can use defined rules to show layer at a specific zoom level. Remember showing geometries is resource intensive, so only show that would be useful at a particular zoom level. For example if zoom levels are defined 1 to 10, where 10 is the highest zoom level, where the whole country would be visible in the application, then at zoom level 10 there is no need to show street level roads or even inter city highways.

Geometry Normalization

After determining the layers and their respective zoom level, there is another optimization technique that I have used in a similar application. That is to normalize geometrical data. For example a major highway line string contains 1 million points connected with each other forming a line string. The reason that particular geometry has so many points is to provide accurate information for navigation, but, these many points would be irrelevant if the major highway is show at the highest zoom level. A normalized geometry object could be used.


The diagram above shows original line string in blue colour, which would have a lot of points, and the red geometry shows normalized geometry with lot fewer points. This could be used at the highest zoom level for showing highways.

Open Source alternatives

There are few open source projects which does the exact same thing and much more. They are:

There are other controls which are available for some licencing fee:


2 thoughts on “Offline mapping in Windows applications using C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s