Ticket #1950 (closed bug: fixed)
Make a Layer.OSM class
| Reported by: | crschmidt | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.8 Release |
| Component: | Layer | Version: | 2.7 |
| Keywords: | Cc: | ||
| State: | Complete |
Description
Right now, OSM is possible to use, but annoying to set up if you're not intimiately familiar with the way OpenLayers works. We've documented this relatively well, but enough people are using this now that it makes sense to pull into core.
Proposal:
- Create an OpenLayers.Layer.XYZ class -- this will be a class which inherits from grid. It is a simple class, essentially providing just a getURL function. This getURL function will support URLs like " http://tile.openstreetmap.org/${z}/${x}/${y}.png"
- Create either a subclass or an option that sets the spherical mercator options by default.
options = OpenLayers.Util.extend({
maxExtent: new OpenLayers.Bounds(-156543.03390625*128,-20037508.34,156543.03390625*128,20037508.34),
maxResolution: 156543.03390625,
numZoomLevels: 19,
units: "m",
projection: "EPSG:900913"
}, options);
var newArguments = [name, url, options];
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments);
Create an OSM layer subclass, which sets:
- A default OSM tile URL
- OSM attribution string.
OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ.SphericalMercator, {
attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
url: "http://tile.openstreetmap.org/${z}/${x}/${y}.png",
CLASS_NAME: "OpenLayers.Layer.OSM"
});
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

