mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-16 16:45:22 +00:00
Add test for containerPointToLatLng and latLngToContainerPoint methods (#8384)
This commit is contained in:

committed by
GitHub

parent
1e97a40b78
commit
383619233c
@ -1965,4 +1965,39 @@ describe("Map", function () {
|
||||
expect(map._layersMinZoom === undefined && map._layersMaxZoom === undefined).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#containerPointToLatLng", function () {
|
||||
|
||||
it("throws if map is not set before", function () {
|
||||
expect(function () {
|
||||
map.containerPointToLatLng();
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it("returns geographical coordinate for point relative to map container", function () {
|
||||
var center = L.latLng(10, 10);
|
||||
map.setView(center, 50);
|
||||
var p = map.containerPointToLatLng(L.point(200, 200));
|
||||
expect(p.lat).to.be.within(10.0000000, 10.0000001);
|
||||
expect(p.lng).to.be.within(10.0000000, 10.0000001);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("#latLngToContainerPoint", function () {
|
||||
|
||||
it("throws if map is not set before", function () {
|
||||
expect(function () {
|
||||
map.latLngToContainerPoint();
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it("returns point relative to map container for geographical coordinate", function () {
|
||||
var center = L.latLng(10, 10);
|
||||
map.setView(center);
|
||||
var p = map.latLngToContainerPoint(center);
|
||||
expect(p.x).to.be.equal(200);
|
||||
expect(p.y).to.be.equal(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user