add Circle & CircleMarker toGeoJSON
This commit is contained in:
parent
9db93e4635
commit
cdc65c6c6b
@ -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]]);
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user