Creating Easy Map Embedding

From OpenStreetMap

Jump to: navigation, search

Google Maps offers an iframe based embedding solution. It would be nice for OSM to do the same.

It would be possible to create an OpenLayers-based static HTML page which can act as an iframe. This page would be static HTML, and would not require much in the way of server resources to actually serve. The 'mvs.html' example in the OpenLayers distribution provides most of the functionality needed, though it would need adapting for the OSM tilesets and projection.

Here is a simple example:

<iframe width="425" height="350" frameborder="0" 
scrolling="no" marginheight="0" marginwidth="0" 
src="http://labs.metacarta.com/osm/embed.html?lat=42&lon=-71&zoom=12&marker=1"></iframe>

Drop this into any web page to get a simple map view. (You can see it in action on my mapping page.)

(The embed.html page is pure Javascript -- no server side -- and can be grabbed and redeployed anywhere under the same license terms as OpenLayers.)

There is a concern that the current OSM infrastructure is not designed for making tiles available to everyone who wants them. With this being the case it is important to solve this technical hurdle before deploying the service: the biggest part of that solution for the Mapnik tiles is going to be the move to mod_tile that jburgess (and others?) is/are working on.

There are additional social hurdles:

  • Does OSM want to serve tiles to J. Random Developer for embedding into his website?
  • What happens if someone popular embeds a map -- is there a limit to the number of tiles served per referrer per day? (OSM, unlike Google, doesn't have infinite hardware.)
    • Unlike Google, OSM has information available on 'how to roll your own'. With that in mind, it's possible to use the 'set up your own if you want to have a lot of load' response to anyone who is likely to exceed the limit.

I will be working on building a version of mvs.html which is suitable for OSM, after which the other technical and social issues can be hashed out if desired.

Personal tools
recent changes