I found myself in need of a C# (.NET/Mono) control for displaying and interacting with maps. I’d already implemented the same functionality in my application using an embedded browser, but that’s a horrible hack, so I decided to implement something nicer. I ended up with this:
I can hear the whining sirens of the don’t-reinvent-the-wheel police approaching already, so a couple of points about that. Yes, there are a couple of projects around already that I could have used almost off the shelf. They’re too complicated for my liking. What I’ve implemented does the basics of what I needed straight away in two small classes, contained in one file. I find this much more pleasant that having to wrangle with someone else’s 25-class monster implementation. Sometimes you can spend more time figuring out how to integrate an external module than you would just writing it yourself, and having spent all that time you still don’t understand the underlying implementation. This becomes more important when you start to extend things further down the line, which I will need to do. I’ve even done all this before, about 7 years ago, using tile data sneakily grabbed from various online proprietary mapping services of the day – I could have used that code, but I even rejected my own wheel.
Furthermore, if all you ever do is piece together other people’s ‘wheels’, you miss out on a lot of understanding, and more importantly fun. I don’t advocate reinventing wheels when someone else is paying for your time or you just need to get something done, but aside from that it’s frequently a good idea. So hopefully the don’t-reinvent-the-wheel police have now gone away to annoy someone else, and I can get back on topic…
Read the rest of this entry »