diff --git a/apidoc_config/Menu.txt b/apidoc_config/Menu.txt index dce22b38d8..93d68c2a33 100644 --- a/apidoc_config/Menu.txt +++ b/apidoc_config/Menu.txt @@ -350,6 +350,7 @@ Group: OpenLayers { File: MapGuide (no auto-title, OpenLayers/Layer/MapGuide.js) File: MapServer (no auto-title, OpenLayers/Layer/MapServer.js) File: Markers (no auto-title, OpenLayers/Layer/Markers.js) + File: OSM (no auto-title, OpenLayers/Layer/OSM.js) File: PointGrid (no auto-title, OpenLayers/Layer/PointGrid.js) File: PointTrack (no auto-title, OpenLayers/Layer/PointTrack.js) File: SphericalMercator (no auto-title, OpenLayers/Layer/SphericalMercator.js) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 506e362cf7..5302ba8bcf 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -144,6 +144,7 @@ "OpenLayers/Layer/GeoRSS.js", "OpenLayers/Layer/Boxes.js", "OpenLayers/Layer/XYZ.js", + "OpenLayers/Layer/OSM.js", "OpenLayers/Layer/Bing.js", "OpenLayers/Layer/TMS.js", "OpenLayers/Layer/TileCache.js", diff --git a/lib/OpenLayers/Layer/OSM.js b/lib/OpenLayers/Layer/OSM.js new file mode 100644 index 0000000000..a1874e3453 --- /dev/null +++ b/lib/OpenLayers/Layer/OSM.js @@ -0,0 +1,91 @@ +/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the Clear BSD license. + * See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/** + * @requires OpenLayers/Layer/XYZ.js + * @requires OpenLayers/Layer/SphericalMercator.js + */ + +/** + * Class: OpenLayers.Layer.OSM + * This layer allows accessing OpenStreetMap tiles. By default the OpenStreetMap + * hosted tile.openstreetmap.org Mapnik tileset is used. If you wish to use + * tiles@home / osmarender layer instead, you need to provide a different + * URL to the constructor. Here's an example for tiles@home: + * + * (code) + * new OpenLayers.Layer.OSM("t@h", + * "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"); + * (end) + * + * Inherits from: + * - + */ +OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { + + /** + * APIProperty: name + * {String} The layer name. Defaults to "OpenStreetMap" if the first + * argument to the constructor is null or undefined. + */ + name: "OpenStreetMap", + + /** + * APIProperty: url + * {String} The tileset URL scheme. Defaults to + * : http://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: + * (start code) + * new OpenLayers.Layer.OSM("t@h", + * "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"); + * (end) + */ + url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', + + /** + * Property: attribution + * {String} The layer attribution. + */ + attribution: "Data CC-By-SA by OpenStreetMap", + + /** + * Property: sphericalMercator + * {Boolean} + */ + sphericalMercator: true, + + /** + * Property: wrapDateLine + * {Boolean} + */ + wrapDateLine: true, + + /** + * Constructor: OpenLayers.Layer.OSM + * + * Parameters: + * 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. + * ). + */ + + /** + * Method: clone + */ + clone: function(obj) { + if (obj == null) { + obj = new OpenLayers.Layer.OSM( + this.name, this.url, this.getOptions()); + } + obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]); + return obj; + }, + + CLASS_NAME: "OpenLayers.Layer.OSM" +}); diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 84855f95be..7977a3255f 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -183,37 +183,3 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { CLASS_NAME: "OpenLayers.Layer.XYZ" }); - - -/** - * Class: OpenLayers.Layer.OSM - * A class to access OpenStreetMap tiles. By default, uses the OpenStreetMap - * hosted tile.openstreetmap.org 'Mapnik' tileset. If you wish to use - * tiles@home / osmarender layer instead, you can pass a layer like: - * - * (code) - * new OpenLayers.Layer.OSM("t@h", - * "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"); - * (end) - * - * This layer defaults to Spherical Mercator. - * - * Inherits from: - * - - */ -OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { - name: "OpenStreetMap", - attribution: "Data CC-By-SA by OpenStreetMap", - sphericalMercator: true, - url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', - clone: function(obj) { - if (obj == null) { - obj = new OpenLayers.Layer.OSM( - this.name, this.url, this.getOptions()); - } - obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]); - return obj; - }, - wrapDateLine: true, - CLASS_NAME: "OpenLayers.Layer.OSM" -}); diff --git a/notes/2.12.md b/notes/2.12.md index 06a2f0ec16..7013846924 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -50,6 +50,10 @@ The base `OpenLayers.Geometry` class no longer depends on `OpenLayers.Format.WKT Without the WKT format included (by default), the `OpenLayers.Geometry::toString` method now returns "[object Object]." Previously, it returned the Well-Known Text representation of the geometry. To maintain the previous behavior, include the OpenLayers/Format/WKT.js file in your build. +## OSM Layer + +`Layer.OSM` is now defined in its own script file, namely `OpenLayers/Layer/OSM.js`. So people using `Layer.OSM` should now include `OpenLayers/Layer/OSM.js`, as opposed to `OpenLayers/Layer/XYZ.js`, in their OpenLayers builds. (See https://github.com/openlayers/openlayers/issues/138) + ## QueryStringFilter `OpenLayers.Protocol.HTTP` no longer requires `OpenLayers.Format.QueryStringFilter`. It you need this, make sure it is included in your build config file. diff --git a/tests/Layer/OSM.html b/tests/Layer/OSM.html new file mode 100644 index 0000000000..fac471caf0 --- /dev/null +++ b/tests/Layer/OSM.html @@ -0,0 +1,16 @@ + + + + + + +
+ + diff --git a/tests/Layer/XYZ.html b/tests/Layer/XYZ.html index d6685c05b5..8b8a7cbf31 100644 --- a/tests/Layer/XYZ.html +++ b/tests/Layer/XYZ.html @@ -251,17 +251,11 @@ } function test_clone(t) { - t.plan(2); - - var clone; + t.plan(1); layer = new OpenLayers.Layer.XYZ(name, url, options); - clone = layer.clone(); + var clone = layer.clone(); t.ok(clone instanceof OpenLayers.Layer.XYZ, "clone is a Layer.XYZ instance"); - - layer = new OpenLayers.Layer.OSM(); - clone = layer.clone(); - t.ok(clone instanceof OpenLayers.Layer.OSM, "clone is a Layer.OSM instance"); } diff --git a/tests/list-tests.html b/tests/list-tests.html index b5beafe9e2..ff53d566bd 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -167,6 +167,7 @@
  • Layer/WMTS.html
  • Layer/WrapDateLine.html
  • Layer/XYZ.html
  • +
  • Layer/OSM.html
  • Map.html
  • Marker.html
  • Marker/Box.html