New to OpenStreetMap...want to embed maps in application


Please excuse me in advance if this isn’t the appropriate forum. If not, could you please tell me which forum in which to post this?

I am working as a software developer on a Windows only based product that needs to have embedded mapping capabilities. Pretty much what I need is the ability to display street information based solely on a point and/or bounding rectangle in lat/long coordinates and then be able to add some annotations (e.g. lines defined by a set of coordinates, push-pins to specific locations or add names to certain points on the map) to the map.

The application I am developing is written in C# using WPF (Windows Presentation Foundation). I have seen a set of WPF controls called “Dynamic Data Display” done by Microsoft Research in Moscow, Russia and one of these controls is a map control that can request data from OpenStreetMap tile servers and displays the data in a WPF control that renders these tile bitmaps from the OpenStreetMap servers. It would be nice to use that control for displaying the maps. However, I don’t think it allows any annotation capability.

My questions pertaining to my basic needs described above are…

  • My understanding is that OpenStreetMap data is most commonly used by requesting data from servers that download maps as bitmapped “tiles”. Is that correct?

  • My understanding is that OpenStreetMap data is actually stored on the servers as XML based “vector graphics” and is rendered to bitmap tiles upon requests to the server. Is that correct?

  • Can I request chunks of data defined by a bounding rectangle from the OpenStreetMap servers in the native XML vector format instead of bitmap tiles?

  • If I can get access to the native XML vector format, can I save off a bounding rectangle’s worth of data as a chunk of XML and then add my annotations to that by simply creating more XML tags?

  • Apparently I can download the entire world OpenStreetMap locally as “planet.osm” file. This file is in the native XML format if I understand correctly. Is that true?

  • If I did download the entire “planet.osm” file locally to avoid needing the Internet for my application, how would I use this data? Do I need to somehow make a local server that serves up chunks of maps as native XML or rendered bitmaps or can I somehow extract a bounding rectangle’s worth of data from the OSM file in some other manner?

  • I think there are ways to convert SVG files to XAML that can be displayed directly in WPF. Is there a way to save OSM files as SVG if I had to use that as an intermediate conversion step?

I assume that other developers have had similar needs as I do for my application. Any approaches to this problem that others have used would be greatly appreciated!

Thanks very much in advance,
Gerard Walschlager

That’s one way, yes.

Not on request. The tiles are re-rendered shortly after an update, but essentially, yes.

Yes, see XAPI on the wiki Also you can export XML from the Export tab on the openstreetmap home page and you can also use the offline editor JOSM to download an area and save it as an XML file.

Yes. You might also like to look at OpenLayers that can overlay your own data on top of the OSM map. See for an idea.

I believe so, yes

There are a number of ways you can render this data, or parts of it. The wiki has details but Kosmos, Osmarender and Mapnik are common ones to use. The main OSM website uses Mapnik and Osmarender (Click on the blue “+” symbol on the top right). Good luck rendering the whole planet with Osmarender though!! (It’s a bit slow!) Maperitive is brand new and still at a very early stage, but is looking really promising so far. Mapnik seems the most advanced but seems complex to set up.

Yes, Osmarender!

Try the osm-newbies and developer mailing lists. They do tend to be a bit more active than the forum.

You’re welcome! Hope this was helpful.

Thanks much Seventy7!

One step I left out is that after downloading the “planet.osm” file, I would need some way of querying that data based on bounding box in lat/long. Therefore, I’ll likely have to create a database and query against it using the bounding box coordinates against OSM XML elements that lie within that box. Is there a relatively straightforward way to do this? Is there already a utility anywhere that can break this OSM XML data out into a database for me? I doubt it…and even if it did, it’s likely that I won’t need all of the information from the OSM XML file anyway.

So, I guess that’s something else I’d have to do: define a schema in my database, parse the OSM XML from the “planet.osm” file and import it as I go (somehow detecting which was the most recent version of elements, and ignore older historical versions). Finally, I’d have to develop queries to retrieve a hierarchy of OSM XML elements that lie within my bounding box request. Once that’s done, I guess that I’d likely render the OSM XML query output on the fly as needed.

I’d like to do this rendering programmatically if possible from within my application and not have to go out to another rendering application if possible. Worst case, I could invoke a command line utility if one exists, but I’d rather embed this rendering within my app. Any suggestions for any of this? Does this order of processing make sense?

Thanks again for your help! There’s sooo much to learn.

Have look at Osmosis
It lets you extract a bounding box from a OSM XML file. It can also import from an XML file into a database.

Also note there are planet.osm extracts available, by continent or country etc. These are much smaller files than the whole world, so easier to download and process.

Thanks for the response Vclaw!

Do you have any experience with the performance of Osmosis? I wonder how quickly it can extract a bounding box of say 25 square kilometers from the “planet.osm” file? If that was fast enough for location tasks, then for my purposes, I don’t even think I’d need to have a database per se. My only real query operation is to query for a bounding box in lat/long. That would be a real savings in development.

Anyone have experience with the performance of Osmosis for this type of usage?

How does “zoom” level that I often see on mapping tools figure in to this type of processing sequence I have discussed? Could I feed the extracted subset XML into something like Mapnik or Osmarender to get SVG output such that it’s still vector graphics and not image tiles? If so, then I could perform any zooming within my presentation control. Or, can I input this extracted subset of XML to Mapnik or Osmarender along with a requested “zoom” level and then have these renderers create image tiles that are already properly zoomed?


As you probably know as a software developer, is that xml format is not an easy workable format, but mainly a data transmission format. That’s why using the planet.osm file in a user interactivity process will fail. I haven’t properly benchmarked this, but extraction with osmosis (or whatever tool you migh try to build) based on a bounding box will need serveral hours as there are no indexes in a .osm file.

What you need is, as far as I know, an in-progress, research territory. I’ve read a few attemps to build binary osm format, and have heard about sqlite spatial databaseformat storing of osm data but belive it is still beta stage. Other data users such as the navit software have build converters to their own format, so are the garmin devices with the help of mkgmap.

I know geofabrik is providing partial export to the shp format (an indexed database file format) but still, it’s early developpement stage as it is not easy to fit all of osm data in this format.

Any planet wide rendering/routing/searching project that needs vector data is first using tools to convert osm files into a database such as postgresSQL with tools like osmosis, osm2pgsql

Has a side note, since your needs aren’t clear to me, if what you need is the ability to add anotation (points ? icons ? texts ?) on a map where “map” is fine has beeing the mapnik rendering, I would probably myself go with making a local copy of the png images, then keep a low size, queryable simple database aside and “just” draw the elements you need on top of the allready copied tiles.
Of course, If you need planet wide coverage at all times without internet connection, storing the images files will be close to impossible has it probably weight something like 1 Terra bytes at zoom 0 to 18

PS: I forgot to mention that kosmos ( is the closer desktop app that comes near your needs. C#, rendering engine for osm files, desktop, database-less (well, internal in fact)