add Circle & CircleMarker toGeoJSON

This commit is contained in:
Vladimir Agafonkin 2013-06-25 12:43:22 -04:00
parent 9db93e4635
commit cdc65c6c6b
2 changed files with 26 additions and 2 deletions

View File

@ -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]]);

View File

@ -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 () {