There are a range of pan and zoom map controls (sometimes called slippy maps) available for C#/.NET and Silverlight/Moonlight. All the ones I’ve seen have something in common – they are bloated. The authors attempt to address the needs of as many users as possible and the result is large downloads and far too many features. The forums and mailing lists are full of people asking how to achieve basic functionality because they are lost in the vast realm of classes.

Of course, it is possible to remove what you don’t need but that requires understanding the code and after all that effort you are left with code that might not have the right license for your needs. The solution? Time to cringe – reinventing the wheel.

Fortunately it’s not much of a wheel, assuming your requirements are simple as mine are. C# and good development tools (Visual Studio and MonoDevelop) makes it easy to quickly develop a lightweight and flexible slippy map that can be used in Windows, Mac OS X and Linux (using Moonlight).

My first attempt at displaying markers worked ok but suffered from poor performance, however I found a few ways to optimize the rendering. As a test I decided to see how far I could push my luck.

Random Rand = new Random();
PerformanceMarkerLayer TestLayer = new PerformanceMarkerLayer("Test");
for (int i = 0; i < 50000; i++)
    TestLayer.Markers.Add(new Marker(new LonLat(Rand.NextDouble() - 1.0,
    Rand.NextDouble() + 53.0)));

This creates a map with 50,000 individually clickable markers. Panning is fluid and zooming has a delay of about six seconds. This is on a cheap Core 2 Duo laptop running off the battery. Interestingly increasing the number of markers to 80,000 does not slow down the panning at all but does increase the zoom delay by 1/3, so it appears that the zoom delay has a linear relationship with the number of markers but the panning does not.

I can already think of several ways of reducing the zoom delay but as I don’t plan on creating maps with this many markers in the near future I will likely leave it for now – too many other things to do.