Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.96k stars 992 forks source link

Why is the circle bigger in CRS.Simple #984

Closed haoxl3 closed 4 years ago

haoxl3 commented 4 years ago

How to reproduce

What behaviour I'm expecting and which behaviour I'm seeing

I use CRS.Simple draw a circle, I have the center coordinates and the radius(They're all in pixels) . Then I draw a cricle , I get a bigger circle. I know that L.cricle of radius in meters, so I use distanceTo get the distance between the two points and I use that as the radius. But the circle looks like have a bigger radius. my code:

let point = {x: 100, y:200};// pixel
let radius = 50; // pixel

const crs = CRS.Simple;
const zoom = this.map.getZoom();

let cc = crs.unproject(point, zoom);
let pointOnCircle = crs.unproject({point.x + radius, point.y}, zoom);
let len = cc.distanceTo(pointOnCircle);

let layer = window.L.circle(cc, {radius: len});
layer.addTo(this.drawnItem); // this.drawnItem = new window.L.FeatureGroup();

Minimal example reproducing the issue