diff --git a/spec/suites/layer/GeoJSONSpec.js b/spec/suites/layer/GeoJSONSpec.js index b111ecc0..3ffc990b 100644 --- a/spec/suites/layer/GeoJSONSpec.js +++ b/spec/suites/layer/GeoJSONSpec.js @@ -33,6 +33,26 @@ describe("L.Marker#toGeoJSON", function () { }); }); +describe("L.Circle#toGeoJSON", function () { + it("returns a Point object", function () { + var circle = new L.Circle([10, 20], 100); + expect(circle.toGeoJSON().geometry).to.eql({ + type: 'Point', + coordinates: [20, 10] + }); + }); +}); + +describe("L.CircleMarker#toGeoJSON", function () { + it("returns a Point object", function () { + var marker = new L.CircleMarker([10, 20]); + expect(marker.toGeoJSON().geometry).to.eql({ + type: 'Point', + coordinates: [20, 10] + }); + }); +}); + describe("L.Polyline#toGeoJSON", function () { it("returns a LineString object", function () { var polyline = new L.Polyline([[10, 20], [2, 5]]); diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index 3bba3e4e..38cc02d6 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -177,14 +177,18 @@ L.extend(L.GeoJSON, { } }); -L.Marker.include({ +var PointToGeoJSON = { toGeoJSON: function () { return L.GeoJSON.getFeature(this, { type: 'Point', coordinates: L.GeoJSON.latLngToCoords(this.getLatLng()) }); } -}); +}; + +L.Marker.include(PointToGeoJSON); +L.Circle.include(PointToGeoJSON); +L.CircleMarker.include(PointToGeoJSON); L.Polyline.include({ toGeoJSON: function () {