mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-15 22:36:58 +00:00
Add test for project method (#9303)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
This commit is contained in:
@ -2219,6 +2219,34 @@ describe('Map', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#project', () => {
|
||||
const tolerance = 1 / 1000000;
|
||||
|
||||
it('returns pixel coordinates relative to the top-left of the CRS extents', () => {
|
||||
map.setView([40, -83], 5);
|
||||
const x = latLng([40, -83]);
|
||||
const a = map.project(x, 5);
|
||||
expect(a.x).to.be.approximately(2207.288888, tolerance);
|
||||
expect(a.y).to.be.approximately(3101.320460, tolerance);
|
||||
});
|
||||
|
||||
it('test the other coordinates', () => {
|
||||
map.setView([40, 83], 5);
|
||||
const x = latLng([40, 83]);
|
||||
const b = map.project(x, 5);
|
||||
expect(b.x).to.be.approximately(5984.7111111, tolerance);
|
||||
expect(b.y).to.be.approximately(3101.3204602, tolerance);
|
||||
});
|
||||
|
||||
it('test the prev coordinates with different zoom', () => {
|
||||
map.setView([40, 83], 5);
|
||||
const x = latLng([40, 83]);
|
||||
const b = map.project(x, 6);
|
||||
expect(b.x).to.be.approximately(11969.422222, tolerance);
|
||||
expect(b.y).to.be.approximately(6202.640920, tolerance);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#latLngToLayerPoint', () => {
|
||||
|
||||
it('throws if map is not set before', () => {
|
||||
|
Reference in New Issue
Block a user