jieter / Leaflet-semicircle

Extend Leaflet's circle class to display semicircles.
http://jieter.github.io/Leaflet-semicircle/examples/semicircle.html
MIT License
123 stars 52 forks source link

Poleward displacement of circle center when radius is large #14

Closed markfaust-sri closed 7 years ago

markfaust-sri commented 7 years ago

If you draw the same semicircle repeatedly with progressively larger radii, you'll see that the centers of the semicircles are farther and farther away from the equator than you intended them to be. The problem does not occur if the circle is centered on the equator and gets progressively worse the closer you get to a pole.

I added some debug to _updateCircle() in Semicircle.js and could see that the Y component of layer._point was already wrong at that point.

I checked this with regular leaflet circles and they are fine.

Here's a code snippet. You can also see this happen if you go into the concentric circle example and crank up the radius. Bigger circles will be displaced north.

  var map = L.map('map').setView([37.403, -122.3317], 11);
  var layer = L.featureGroup();
  var pieColor = ['#000', '#FF0000', '#00FF00'];
  // 3 sets of pie wedges, 1 on the equator, 1 at 20 N/S, 1 at 40 N/S
  for (j = 0; j < 3; j++) {
      // 6 progressively bigger pie wedges
      for (i = 0; i < 6; i ++) {
        // draw some in the N hemisphere and some in the S
        for (k = 1; k > -2; k -= 2) {
          L.circle([k*j * 20.0, -71.484704], {
                    radius:   i * 200000,
                    fill: true,
                    color: pieColor[j],
                    weight: 1
                // point due `East`
                }).setDirection(90, 45.0).addTo(layer);
        }  
      }
  }    
  layer.addTo(map);
avidspartan1 commented 7 years ago

I'm also seeing this behavior. What's the issue?

avidspartan1 commented 7 years ago

Addressed with PR https://github.com/jieter/Leaflet-semicircle/pull/23 (I think).

jieter commented 7 years ago

Should be fixed by #23 (just merged)