Merge branch 'master' of https://github.com/Leaflet/Leaflet
* 'master' of https://github.com/Leaflet/Leaflet: Add test specifications for CRS classes. Fixing wrong EPGS3395 transformation Renamed Tooltip to Title Again some whitespace removing. (Travis) Code style adjusted for travis. Localization Support for Zoom Control
This commit is contained in:
commit
1b8f5c6ece
@ -23,4 +23,20 @@ if (!Array.prototype.map) {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect.Assertion.prototype.near = function(expected, delta) {
|
||||||
|
delta = delta || 1;
|
||||||
|
expect(this.obj.x).to
|
||||||
|
.be.within(expected.x - delta, expected.x + delta);
|
||||||
|
expect(this.obj.y).to
|
||||||
|
.be.within(expected.y - delta, expected.y + delta);
|
||||||
|
};
|
||||||
|
|
||||||
|
expect.Assertion.prototype.nearLatLng = function(expected, delta) {
|
||||||
|
delta = delta || 1e-4;
|
||||||
|
expect(this.obj.lat).to
|
||||||
|
.be.within(expected.lat - delta, expected.lat + delta);
|
||||||
|
expect(this.obj.lng).to
|
||||||
|
.be.within(expected.lng - delta, expected.lng + delta);
|
||||||
|
};
|
47
spec/suites/geo/CRSSpec.js
Normal file
47
spec/suites/geo/CRSSpec.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
describe("CRS.EPSG3395", function() {
|
||||||
|
var crs = L.CRS.EPSG3395;
|
||||||
|
|
||||||
|
describe("#latLngToPoint", function() {
|
||||||
|
it("projects a center point", function() {
|
||||||
|
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("projects the northeast corner of the world", function() {
|
||||||
|
expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#pointToLatLng", function() {
|
||||||
|
it("reprojects a center point", function() {
|
||||||
|
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("reprojects the northeast corner of the world", function() {
|
||||||
|
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("CRS.EPSG3857", function() {
|
||||||
|
var crs = L.CRS.EPSG3857;
|
||||||
|
|
||||||
|
describe("#latLngToPoint", function() {
|
||||||
|
it("projects a center point", function() {
|
||||||
|
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("projects the northeast corner of the world", function() {
|
||||||
|
expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#pointToLatLng", function() {
|
||||||
|
it("reprojects a center point", function() {
|
||||||
|
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("reprojects the northeast corner of the world", function() {
|
||||||
|
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,14 +1,6 @@
|
|||||||
describe("Projection.Mercator", function() {
|
describe("Projection.Mercator", function() {
|
||||||
var p = L.Projection.Mercator;
|
var p = L.Projection.Mercator;
|
||||||
|
|
||||||
expect.Assertion.prototype.near = function(expected, delta) {
|
|
||||||
delta = delta || 1;
|
|
||||||
expect(this.obj.x).to
|
|
||||||
.be.within(expected.x - delta, expected.x + delta);
|
|
||||||
expect(this.obj.y).to
|
|
||||||
.be.within(expected.y - delta, expected.y + delta);
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("#project", function() {
|
describe("#project", function() {
|
||||||
it("projects a center point", function() {
|
it("projects a center point", function() {
|
||||||
//edge cases
|
//edge cases
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
L.Control.Zoom = L.Control.extend({
|
L.Control.Zoom = L.Control.extend({
|
||||||
options: {
|
options: {
|
||||||
position: 'topleft'
|
position: 'topleft',
|
||||||
|
zoomInText: '+',
|
||||||
|
zoomInTitle: 'Zoom in',
|
||||||
|
zoomOutText: '-',
|
||||||
|
zoomOutTitle: 'Zoom out'
|
||||||
},
|
},
|
||||||
|
|
||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
@ -14,9 +18,11 @@ L.Control.Zoom = L.Control.extend({
|
|||||||
this._map = map;
|
this._map = map;
|
||||||
|
|
||||||
this._zoomInButton = this._createButton(
|
this._zoomInButton = this._createButton(
|
||||||
'+', 'Zoom in', zoomName + '-in', container, this._zoomIn, this);
|
this.options.zoomInText, this.options.zoomInTitle,
|
||||||
|
zoomName + '-in', container, this._zoomIn, this);
|
||||||
this._zoomOutButton = this._createButton(
|
this._zoomOutButton = this._createButton(
|
||||||
'-', 'Zoom out', zoomName + '-out', container, this._zoomOut, this);
|
this.options.zoomOutText, this.options.zoomOutTitle,
|
||||||
|
zoomName + '-out', container, this._zoomOut, this);
|
||||||
|
|
||||||
map.on('zoomend zoomlevelschange', this._updateDisabled, this);
|
map.on('zoomend zoomlevelschange', this._updateDisabled, this);
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ L.CRS.EPSG3395 = L.extend({}, L.CRS, {
|
|||||||
transformation: (function () {
|
transformation: (function () {
|
||||||
var m = L.Projection.Mercator,
|
var m = L.Projection.Mercator,
|
||||||
r = m.R_MAJOR,
|
r = m.R_MAJOR,
|
||||||
r2 = m.R_MINOR;
|
scale = 0.5 / (Math.PI * r);
|
||||||
|
|
||||||
return new L.Transformation(0.5 / (Math.PI * r), 0.5, -0.5 / (Math.PI * r2), 0.5);
|
return new L.Transformation(scale, 0.5, -scale, 0.5);
|
||||||
}())
|
}())
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user