↑ OpenStreetmap Hacker's guide ↑↑ Net & Web  

The OpenStreetmap web map

Locations -- Routes -- Objects

The most well-known part of OpenStreetmap is certainly its map web app, so before we start on the hackery, here is an overview of what you can do with it and how you can construct URLs for its features. That allows you to generate such URLs automatically, for example to link to a varying location from a script on your own website.


The most basic map URL describing a specific location and region of the map has the following form:


The latitude and longitude refer to the location of the centre of the map, the zoom level gives its scale. In zoom level 13, the scale is ≈ 13 metres per pixel. Larger zoom values give a more accurate scale, and successive zoom levels differ by a factor 2.

Something to bear in mind when sending hyperlinks to OpenStreetmap web maps around ist that the size of the map section cannot be fixed, but will depend on the size of the browser window in which they are viewed.

The fact that the latitude and longitude of the centre point of the map are URL parameters can be used to obtain the coordinates of a point on the map. Selecting the option "Centre map here" in the right-click context menu centres the map on that point and puts its coordinates in the URL.

Further features are enabled by other parameters in the URL. Some of these have to be put before, some after the map location. A parameter after the location can for example be used to select a "map layer" (map appearance). The following example selects the OpenCycleMap style:


The following map styles are available:

Style URL suffix
Standard (none)
Cycle Map &layers=C
Transport Map &layers=T
Mapquest Open &layers=Q
Humanitarian &layers=H

A marker can be put into the map by appending parameters before the map location:


When the map location part is omitted, the map will be displayed at the marker location at zoom level 12, ≈ 26 metres / pixel. Unless you have a machine-readable source of locations, you have to copy the marker location from the map location you adjusted interactively. For a different way of marking buildings and streets, see under Objects below.


OpenStreetmap's routing app is accessed via the base URL http://www.openstreetmap.org/directions. When specifying place names for OpenStreetmap to resolve, the parameters from and to are used, as in this example:


More complex locations such as addresses can be given instead of place names, they only have to be URL encoded.

If one or both endpoints of the route are not place names in the OpenStreetmap database (such an arbitrary point on a highway), the geocoordinates of both endpoints have to be given explicitly. This is the format into which the routing URL is converted automatically after looking up place names. It uses a single parameter route which contains both endpoints in the format <start latitude>,<start longitude>;<destination latitude>,<destination longitude>. The separating commas and semicolon have to be URL encoded. An example:


OpenStreetmap offers multiple routing engines. They are selected with the engine parameter. The following choices were available at some time in the past &emdash; there are fewer now, but I list all of them for completeness (the unavailable ones are redirected to one for the same means of transport):

Routing engine Value of engine parameter
Car (OSRM) (default) osrm_car
Car (Mapzen) mapzen_car
Car (GraphHopper) graphhopper_car
Bicycle (Mapzen) mapzen_bicycle
Bicycle (GraphHopper) graphhopper_bicycle
Foot (Mapzen) mapzen_foot
Foot (GraphHopper) graphhopper_foot

The routing for the different modes of transport differs in the time computation and the available roads, and different algorithms for the same mode of transport sometimes prefer different routes.

All routing URL parameters have to precede a map location fragment, when present.


OpenStreetmap also allows to mark map objects in the online map. As will be explained on the contribution page, OpenStreetmap map data consists of nodes (points) and paths (polylines between points, possibly closed). Buildings are represented by closed paths, and if you search for an address, they are marked in the map view, resulting in a URL of the following form:


Streets are open paths and can also be found by the web map search:


If you are used to editing OpenStreetmap data, you can also mark ordinary points that cannot be found by their metadata, such as an arbitrary point on a road:


One should note that these IDs are not permanent, but may change if someone edits the map data. But for good quality map regions, that is not likely to happen frequently.

Licensed under the Creative Commons Attribution-Share Alike 3.0 Germany License

TOS / Impressum