This layer allows accessing OpenStreetMap tiles. By default the OpenStreetMap hosted tile.openstreetmap.org Mapnik tileset is used. If you wish to use a different layer instead, you need to provide a different URL to the constructor. Here’s an example for using OpenCycleMap:
new OpenLayers.Layer.OSM("OpenCycleMap", ["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"]);
OpenLayers.
|
This layer allows accessing OpenStreetMap tiles. |
Properties | |
name | {String} The layer name. |
url | {String} The tileset URL scheme. |
tileOptions | {Object} optional configuration options for OpenLayers.Tile instances created by this Layer. |
Constructor | |
OpenLayers.
|
{String} The tileset URL scheme. Defaults to
http://[a|b|c].tile.openstreetmap.org/${z}/${x}/${y}.png
(the official OSM tileset) if the second argument to the constructor is null or undefined. To use another tileset you can have something like this:
new OpenLayers.Layer.OSM("OpenCycleMap", ["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png", "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"]);
{Object} optional configuration options for OpenLayers.Tile instances created by this Layer. Default is
{crossOriginKeyword: 'anonymous'}
When using OSM tilesets other than the default ones, it may be necessary to set this to
{crossOriginKeyword: null}
if the server does not send Access-Control-Allow-Origin headers.
name | {String} The layer name. |
url | {String} The tileset URL scheme. |
options | {Object} Configuration options for the layer. Any inherited layer option can be set in this object (e.g. OpenLayers.Layer.Grid.buffer). |