Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Rename L.TileJSON.Layer -> L.TileJSON.LayerGroup (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Feb 19, 2013
1 parent 731ced0 commit c794c08
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/legend.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script type='text/javascript'>
var map = L.map('map')
.setView([0, 0], 3)
.addLayer(L.TileJSON.layer('examples.map-zmy97flj'));
.addLayer(L.TileJSON.layerGroup('examples.map-zmy97flj'));

mapbox.legend().addTo(map);
</script>
Expand Down
4 changes: 2 additions & 2 deletions examples/opacity.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
// has a race condition currently
// and we need to refactor this when leaflet gets named and indexed layers

var overlay = L.TileJSON.layer('aibram.Aerial');
var overlay = L.TileJSON.layerGroup('aibram.Aerial');
var map = L.map('map')
.setView([0, 0], 3)
.addLayer(L.TileJSON.layer('examples.map-vyofok3q'))
.addLayer(L.TileJSON.layerGroup('examples.map-vyofok3q'))
.addLayer(overlay);

var handle = document.getElementById('handle'),
Expand Down
2 changes: 1 addition & 1 deletion examples/tilejson.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script type='text/javascript'>
var map = L.map('map')
.setView([0, 0], 3)
.addLayer(L.TileJSON.layer('http://api.tiles.mapbox.com/v3/examples.map-zr0njcqy.json'));
.addLayer(L.TileJSON.layerGroup('http://api.tiles.mapbox.com/v3/examples.map-zr0njcqy.json'));
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions src/tilejson.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ L.TileJSON = {
// A layer that loads its metadata from an endpoint that distributes TileJSON.
// From that endpoint it gets a center, zoom level, attribution, zoom
// extent, and more.
L.TileJSON.Layer = L.LayerGroup.extend({
L.TileJSON.LayerGroup = L.LayerGroup.extend({

_tilejson: {},

Expand Down Expand Up @@ -103,6 +103,6 @@ L.TileJSON.Layer = L.LayerGroup.extend({
}
});

L.TileJSON.layer = function(url) {
return new L.TileJSON.Layer(url);
L.TileJSON.layerGroup = function(url) {
return new L.TileJSON.LayerGroup(url);
};
12 changes: 6 additions & 6 deletions test/spec/tilejson.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("L.TileJSON", function() {
});
});

describe("Layer", function() {
describe("LayerGroup", function() {
function layersOf(layerGroup) {
var result = [];
layerGroup.eachLayer(function(layer) {
Expand All @@ -87,34 +87,34 @@ describe("L.TileJSON", function() {
}

it("creates a TileLayer with the appropriate min and max zoom", function() {
var group = new L.TileJSON.Layer(tileJSON),
var group = new L.TileJSON.LayerGroup(tileJSON),
layers = layersOf(group);

expect(layers[0].options.minZoom).to.equal(1);
expect(layers[0].options.maxZoom).to.equal(11);
});

it("allows access to the tilejson object after assignment", function() {
var layer = new L.TileJSON.Layer(tileJSON);
var layer = new L.TileJSON.LayerGroup(tileJSON);
expect(layer.tilejson()).to.equal(tileJSON);
});

it("creates a TileLayer with the appropriate attribution", function() {
var group = new L.TileJSON.Layer(tileJSON),
var group = new L.TileJSON.LayerGroup(tileJSON),
layers = layersOf(group);

expect(layers[0].options.attribution).to.equal('Terms & Feedback');
});

it("creates a TileLayer with the appropriate tms option", function() {
var group = new L.TileJSON.Layer(L.extend({}, tileJSON, {scheme: 'tms'})),
var group = new L.TileJSON.LayerGroup(L.extend({}, tileJSON, {scheme: 'tms'})),
layers = layersOf(group);

expect(layers[0].options.tms).to.equal(true);
});

it("customizes the TileLayer's getTileUrl method", function() {
var group = new L.TileJSON.Layer(tileJSON),
var group = new L.TileJSON.LayerGroup(tileJSON),
layer = layersOf(group)[0];

expect(layer.getTileUrl({x: 0, y: 0, z: 0})).to.equal('http://a.tiles.mapbox.com/v3/examples.map-zr0njcqy/0/0/0.png');
Expand Down

0 comments on commit c794c08

Please sign in to comment.