accept coordinates in form of simple objects, close #1412
This commit is contained in:
parent
5d41efe616
commit
a0dd4a60e9
@ -105,6 +105,14 @@ describe('LatLng', function() {
|
||||
it('should create a LatLng object from two coordinates', function () {
|
||||
expect(L.latLng(50, 30)).toEqual(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('should accept an object with lat/lng', function () {
|
||||
expect(L.latLng({lat: 50, lng: 30})).toEqual(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('should accept an object with lat/lon', function () {
|
||||
expect(L.latLng({lat: 50, lon: 30})).toEqual(new L.LatLng(50, 30));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -80,6 +80,9 @@ L.latLng = function (a, b) { // (LatLng) or ([Number, Number]) or (Number, Numbe
|
||||
if (a === undefined || a === null) {
|
||||
return a;
|
||||
}
|
||||
if (typeof a === 'object' && 'lat' in a) {
|
||||
return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon);
|
||||
}
|
||||
return new L.LatLng(a, b);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user