diff --git a/src/leaflet/core/Base.js b/src/leaflet/core/Base.js index f59cf83211..b1a264ce83 100644 --- a/src/leaflet/core/Base.js +++ b/src/leaflet/core/Base.js @@ -30,7 +30,7 @@ function wrapToGeoJSON(objClassArray) { objClass.defaultFunction = objClass.prototype.toGeoJSON; objClass.include({ toGeoJSON: function (precision) { - return objClass.defaultFunction.call(this, precision || 10); + return objClass.defaultFunction.call(this, precision || L.toGeoJSONPrecision || 15); } }) return objClass; diff --git a/test/leaflet/core/BaseSpec.js b/test/leaflet/core/BaseSpec.js new file mode 100644 index 0000000000..1cab1f9add --- /dev/null +++ b/test/leaflet/core/BaseSpec.js @@ -0,0 +1,14 @@ +import '../../../src/leaflet/core/Base'; +import L from "leaflet"; + +describe('Base', () => { + it("toGeoJSON precision", () => { + const p = L.marker([10.12345678912345, 4.12345678912345]); + expect(p.toGeoJSON().geometry.coordinates[0]).toEqual(4.12345678912345); + }); + it("toGeoJSON toGeoJSONPrecision", () => { + L.toGeoJSONPrecision = 8; + const p = L.marker([10.12345678912345, 4.12345678912345]); + expect(p.toGeoJSON().geometry.coordinates[0]).toEqual(4.12345679); + }); +}); \ No newline at end of file diff --git a/test/test-main-leaflet.js b/test/test-main-leaflet.js index c495f69c85..f0313d039b 100644 --- a/test/test-main-leaflet.js +++ b/test/test-main-leaflet.js @@ -5,6 +5,7 @@ import './leaflet/control/ChangeTileVersionSpec.js'; import './leaflet/core/NonEarthCRSSpec.js'; import './leaflet/core/TransformUtilSpec.js'; import './leaflet/core/Proj4LeafletSpec.js'; +import './leaflet/core/BaseSpec.js'; /*leaflet -- mapping*/ import './leaflet/mapping/ImageMapLayerSpec.js';