move Layer.OSM in its own script file

This commit is contained in:
Éric Lemoine
2012-01-12 21:22:58 +01:00
parent 2d7fa6810a
commit 3cbd7b4b40
8 changed files with 66 additions and 42 deletions

View File

@@ -362,6 +362,7 @@ Group: OpenLayers {
File: MapServer.Untiled (no auto-title, OpenLayers/Layer/MapServer/Untiled.js)
File: Markers (no auto-title, OpenLayers/Layer/Markers.js)
File: MultiMap (no auto-title, OpenLayers/Layer/MultiMap.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)

View File

@@ -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",

View File

@@ -0,0 +1,41 @@
/* 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
*/
/**
* 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.XYZ>
*/
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
name: "OpenStreetMap",
attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
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"
});

View File

@@ -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.XYZ>
*/
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
name: "OpenStreetMap",
attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
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"
});

View File

@@ -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)
## Deprecated Components
A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate `<script>` tag after OpenLayers.js).

16
tests/Layer/OSM.html Normal file
View File

@@ -0,0 +1,16 @@
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_clone(t) {
t.plan(1);
var layer = new OpenLayers.Layer.OSM();
var clone = layer.clone();
t.ok(clone instanceof OpenLayers.Layer.OSM, "clone is a Layer.OSM instance");
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>

View File

@@ -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");
}
</script>

View File

@@ -167,6 +167,7 @@
<li>Layer/WMTS.html</li>
<li>Layer/WrapDateLine.html</li>
<li>Layer/XYZ.html</li>
<li>Layer/OSM.html</li>
<li>Map.html</li>
<li>Marker.html</li>
<li>Marker/Box.html</li>