diff --git a/docs/reference-1.4.0.html b/docs/reference-1.4.0.html index 076944a6f17..cec341bf242 100644 --- a/docs/reference-1.4.0.html +++ b/docs/reference-1.4.0.html @@ -2543,7 +2543,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the marker (as a GeoJSON Point Feature).

@@ -8702,7 +8702,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the polyline (as a GeoJSON LineString or MultiLineString Feature).

@@ -9568,7 +9568,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the polygon (as a GeoJSON Polygon or MultiPolygon Feature).

@@ -10464,7 +10464,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the polygon (as a GeoJSON Polygon or MultiPolygon Feature).

@@ -11361,7 +11361,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the circle marker (as a GeoJSON Point Feature).

@@ -12143,7 +12143,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the circle marker (as a GeoJSON Point Feature).

@@ -13922,7 +13922,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

@@ -14597,7 +14597,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

@@ -15381,7 +15381,7 @@

Methods

- toGeoJSON() + toGeoJSON(<Number> precision) Object

Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

diff --git a/spec/suites/core/UtilSpec.js b/spec/suites/core/UtilSpec.js index 979dcdca605..fdc70687d04 100644 --- a/spec/suites/core/UtilSpec.js +++ b/spec/suites/core/UtilSpec.js @@ -86,6 +86,9 @@ describe('Util', function () { expect(L.Util.formatNum(13.12325555, 3)).to.eql(13.123); expect(L.Util.formatNum(13.12325555)).to.eql(13.123256); expect(L.Util.formatNum(13.12325555, 0)).to.eql(13); + expect(L.Util.formatNum(1.005, 2)).to.eql(1.01); + expect(L.Util.formatNum(1.555, 2)).to.eql(1.56); + expect(L.Util.formatNum(-1.4837191022531273, 18)).to.eql(-1.4837191022531273); }); }); diff --git a/spec/suites/layer/GeoJSONSpec.js b/spec/suites/layer/GeoJSONSpec.js index 944e9edc522..429f5390a25 100644 --- a/spec/suites/layer/GeoJSONSpec.js +++ b/spec/suites/layer/GeoJSONSpec.js @@ -80,6 +80,12 @@ describe("L.Marker#toGeoJSON", function () { type: 'Point', coordinates: [20.123, 10.123, 30.123] }); + + marker = new L.Marker({lng: -1.4837191022531273, lat: 43.49222084042808}); + expect(marker.toGeoJSON(18).geometry).to.eql({ + type: 'Point', + coordinates: [-1.4837191022531273, 43.49222084042808] + }); }); }); diff --git a/src/core/Util.js b/src/core/Util.js index f3d22ece0c5..9399c86e7e8 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -114,8 +114,8 @@ export function falseFn() { return false; } // @function formatNum(num: Number, digits?: Number): Number // Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default. export function formatNum(num, digits) { - var pow = Math.pow(10, (digits === undefined ? 6 : digits)); - return Math.round(num * pow) / pow; + digits = (digits === undefined ? 6 : digits); + return +(Math.round(num + ('e+' + digits)) + ('e-' + digits)); } // @function trim(str: String): String