[OSM-dev] CORS headers on OSM tiles (for WebGL use)

klokan at gmail.com klokan at gmail.com
Sat Sep 17 22:46:15 BST 2011


Dear OSM developers,

Would it be possible to add the CORS HTTP header: Access-Control-Allow-Origin: *
to the OSM tileserver when a tile is requested?

It will officially allow to use the OSM tiles as WebGL textures and
Canvas source in web browser - both in 3D globes and 2D applications
(color adjustments, etc).

The older browsers such as FF4+ or Chrome9+ support the loading of
WebGL textures cross-domain directly without restrictions. Then in
July 2011 (FF5+, Chrome15+) restrictions were introduced - when the
only workaround was to place a copy of all textures (map tiles) on
your own server or run a web proxy. The WebGL standard was since then
updated - with CORS header on server side as the official solution.
The newest browsers (FF8+ or Chrome 14+ beta and other WebKit-based)
now implements the CORS headers correctly. It is upon server
administrators to explicitly allow usage of images as WebGL textures
and Canvas source.

If the mentioned header is present, then JavaScript code is allowed to
read the pixel values from the images (map tiles).
I can't see how this could be misused, especially in case of
OpenStreetMap tiles, when the whole project is really open and
community driven.

Technically it is quite an easy task to introduce the HTTP header,
either by configuring the webserver (look at http://enable-cors.org/)
or by patching mod_tile (this would be great IMHO). I discussed this
issue at #osm-dev today, during FOSS4G coding sprint in Denver. I can
also prepare a patch if it would help to make this happen...
It would be great to have this turned on also on the MapQuest tile servers.

BTW Google Maps tile servers already provides the CORS headers, as
well as hosting of images published on Picasa/Google+.

Please, turn this header on! Or is there any reason why not to do that?

Best regards,

Klokan Petr Pridal

P.S.
I am one of the authors of open-source project WebGL Earth. It is a 3D
virtual globe written in JavaScript, you can try it at:
http://www.webglearth.com/ with FF4+ or Chrome9+, if you have a
supported graphic card and correctly installed drivers. We are using
the OSM and MapQuest tiles and visualizing them in 3D, support for
terrain and 3d buildings is already partly implemented in the
dev-branches available at GitHub. We have also very easy to use
JavaScript API. Read more about the project at
http://www.webglearth.org/.
--
http://blog.klokantech.com/
http://www.maptiler.org/
http://www.oldmapsonline.org/



More information about the dev mailing list