mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-25 01:32:21 +00:00
Fix circle radius if L.CRS.Simple has inverted x axis (#9414)
Co-authored-by: Jerry Lin <jerrylin2488@gmail.com> Co-authored-by: Aaron Sharif <aaronsharif62@gmail.com> Co-authored-by: Florian Bischof <design.falke@gmail.com>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import {expect} from 'chai';
|
||||
import {Circle, Map} from 'leaflet';
|
||||
import {Circle, Map, Util, CRS, Transformation} from 'leaflet';
|
||||
import {createContainer, removeMapContainer} from '../../SpecHelper.js';
|
||||
|
||||
describe('Circle', () => {
|
||||
@ -47,4 +47,22 @@ describe('Circle', () => {
|
||||
expect(bounds.getNorthEast()).nearLatLng([50.00179, 30.00279]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('CRS Simple', () => {
|
||||
it('returns a positive radius if the x axis of L.CRS.Simple is inverted', () => {
|
||||
map.remove();
|
||||
|
||||
const crs = Util.extend(CRS.Simple, {
|
||||
transformation: new Transformation(-1, 0, -1, 0),
|
||||
});
|
||||
map = new Map(container, {
|
||||
crs
|
||||
});
|
||||
map.setView([0, 0], 4);
|
||||
|
||||
const circle = new Circle([0, 0], {radius: 200}).addTo(map);
|
||||
|
||||
expect(circle._radius).to.eql(3200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -94,7 +94,7 @@ export const Circle = CircleMarker.extend({
|
||||
const latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._mRadius, 0]));
|
||||
|
||||
this._point = map.latLngToLayerPoint(this._latlng);
|
||||
this._radius = this._point.x - map.latLngToLayerPoint(latlng2).x;
|
||||
this._radius = Math.abs(this._point.x - map.latLngToLayerPoint(latlng2).x);
|
||||
}
|
||||
|
||||
this._updateBounds();
|
||||
|
Reference in New Issue
Block a user