Codebase list leaflet / cdc65c6
add Circle & CircleMarker toGeoJSON Vladimir Agafonkin 10 years ago
2 changed file(s) with 26 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2525 describe("L.Marker#toGeoJSON", function () {
2626 it("returns a Point object", function () {
2727 var marker = new L.Marker([10, 20]);
28 expect(marker.toGeoJSON().geometry).to.eql({
29 type: 'Point',
30 coordinates: [20, 10]
31 });
32 });
33 });
34
35 describe("L.Circle#toGeoJSON", function () {
36 it("returns a Point object", function () {
37 var circle = new L.Circle([10, 20], 100);
38 expect(circle.toGeoJSON().geometry).to.eql({
39 type: 'Point',
40 coordinates: [20, 10]
41 });
42 });
43 });
44
45 describe("L.CircleMarker#toGeoJSON", function () {
46 it("returns a Point object", function () {
47 var marker = new L.CircleMarker([10, 20]);
2848 expect(marker.toGeoJSON().geometry).to.eql({
2949 type: 'Point',
3050 coordinates: [20, 10]
176176 }
177177 });
178178
179 L.Marker.include({
179 var PointToGeoJSON = {
180180 toGeoJSON: function () {
181181 return L.GeoJSON.getFeature(this, {
182182 type: 'Point',
183183 coordinates: L.GeoJSON.latLngToCoords(this.getLatLng())
184184 });
185185 }
186 });
186 };
187
188 L.Marker.include(PointToGeoJSON);
189 L.Circle.include(PointToGeoJSON);
190 L.CircleMarker.include(PointToGeoJSON);
187191
188192 L.Polyline.include({
189193 toGeoJSON: function () {