fix Circle in flat projections
This commit is contained in:
parent
8f4baaed14
commit
ae8bc579a4
@ -32,26 +32,31 @@ L.Circle = L.CircleMarker.extend({
|
||||
|
||||
_project: function () {
|
||||
|
||||
var rad = Math.PI / 180,
|
||||
lng = this._latlng.lng,
|
||||
var lng = this._latlng.lng,
|
||||
lat = this._latlng.lat,
|
||||
map = this._map,
|
||||
crs = map.options.crs;
|
||||
|
||||
latR = (this._mRadius / L.CRS.Earth.R) / rad,
|
||||
if (crs.distance === L.CRS.Earth.distance) {
|
||||
var d = Math.PI / 180,
|
||||
latR = (this._mRadius / L.CRS.Earth.R) / d,
|
||||
top = map.project([lat + latR, lng]),
|
||||
bottom = map.project([lat - latR, lng]),
|
||||
p = top.add(bottom).divideBy(2),
|
||||
lat2 = map.unproject(p).lat,
|
||||
|
||||
lngR = Math.acos((Math.cos(latR * rad) - Math.sin(lat * rad) * Math.sin(lat2 * rad)) /
|
||||
(Math.cos(lat * rad) * Math.cos(lat2 * rad))) / rad || 0,
|
||||
left = map.project([lat2, lng - lngR]),
|
||||
r = p.x - left.x,
|
||||
ry = p.y - top.y;
|
||||
lngR = Math.acos((Math.cos(latR * d) - Math.sin(lat * d) * Math.sin(lat2 * d)) /
|
||||
(Math.cos(lat * d) * Math.cos(lat2 * d))) / d;
|
||||
|
||||
this._point = p.subtract(map.getPixelOrigin());
|
||||
this._radius = r ? Math.max(Math.round(r), 1) : 0;
|
||||
this._radiusY = Math.max(Math.round(ry), 1);
|
||||
this._radius = isNaN(lngR) ? 0 : Math.max(Math.round(p.x - map.project([lat2, lng - lngR]).x), 1);
|
||||
this._radiusY = Math.max(Math.round(p.y - top.y), 1);
|
||||
|
||||
} else {
|
||||
var 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._updateBounds();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user