Permalink
Browse files

Fixed Circle rendering with incorrect radius, closed #331

  • Loading branch information...
mourner committed Oct 14, 2011
1 parent d0d6b08 commit ae17553f56b44fd45e965c187faf5a3612a02e6c
Showing with 12 additions and 6 deletions.
  1. +1 −0 CHANGELOG.md
  2. +3 −3 dist/leaflet.js
  3. +8 −3 src/layer/vector/Circle.js
View
@@ -44,6 +44,7 @@ Leaflet Changelog
* Fixed a bug where map panning would stuck forever after releasing the mouse over an iframe or a flash object (thanks to [@sten82](https://github.com/sten82)). [#297](https://github.com/CloudMade/Leaflet/pull/297) [#64](https://github.com/CloudMade/Leaflet/issues/64)
* Fixed a bug where mouse zoom worked incorrectly if map is inside scrolled container (partially by [@chrillo](https://github.com/chrillo)). [#206](https://github.com/CloudMade/Leaflet/issues/206)
* Fixed a bug where it was possible to add the same listener twice. [#281](https://github.com/CloudMade/Leaflet/issues/281)
+ * Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exagerration into account). [#331](https://github.com/CloudMade/Leaflet/issues/331)
* Fixed a bug where `Marker` `setIcon` was not working properly (by [@marphi](https://github.com/marphi)). [#218](https://github.com/CloudMade/Leaflet/pull/218) [#311](https://github.com/CloudMade/Leaflet/issues/311)
* Fixed a bug where `Marker` `setLatLng` was not working if it's set before adding the marker to a map. [#222](https://github.com/CloudMade/Leaflet/issues/222)
* Fixed a bug where static properties of a child class would not override the parent ones.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -28,10 +28,15 @@ L.Circle = L.Path.extend({
projectLatlngs: function() {
var equatorLength = 40075017,
- scale = this._map.options.scale(this._map._zoom);
-
+ scale = this._map.options.scale(this._map._zoom),
+ hLength = equatorLength * Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat);
+
+ var lngSpan = (this._mRadius / hLength) * 360,
+ latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngSpan, true),
+ point2 = this._map.latLngToLayerPoint(latlng2);
+
this._point = this._map.latLngToLayerPoint(this._latlng);
- this._radius = (this._mRadius / equatorLength) * scale;
+ this._radius = Math.round(this._point.x - point2.x);
},
getPathString: function() {

0 comments on commit ae17553

Please sign in to comment.