Merge pull request #144 from elemoine/osm
move Layer.OSM in its own file
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
91
lib/OpenLayers/Layer/OSM.js
Normal file
91
lib/OpenLayers/Layer/OSM.js
Normal file
@@ -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.XYZ>
|
||||
*/
|
||||
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 <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* <OpenLayers.Layer.Grid.buffer>).
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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"
|
||||
});
|
||||
@@ -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"
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
|
||||
16
tests/Layer/OSM.html
Normal file
16
tests/Layer/OSM.html
Normal 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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user