Merge pull request #3070 from lonelyelk/latlng-factory-altitude
Factory L.latLng to accept altitude
This commit is contained in:
commit
7cafaa6346
@ -103,6 +103,15 @@ describe('LatLng', function () {
|
||||
it('returns null if lng not specified', function () {
|
||||
expect(L.latLng(50)).to.be(null);
|
||||
});
|
||||
|
||||
it('accepts altitude as third parameter', function () {
|
||||
expect(L.latLng(50, 30, 100)).to.eql(new L.LatLng(50, 30, 100));
|
||||
});
|
||||
|
||||
it('accepts an object with alt', function () {
|
||||
expect(L.latLng({lat: 50, lng: 30, alt:100})).to.eql(new L.LatLng(50, 30, 100));
|
||||
expect(L.latLng({lat: 50, lon: 30, alt:100})).to.eql(new L.LatLng(50, 30, 100));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -56,7 +56,7 @@ L.LatLng.prototype = {
|
||||
// constructs LatLng with different signatures
|
||||
// (LatLng) or ([Number, Number]) or (Number, Number) or (Object)
|
||||
|
||||
L.latLng = function (a, b) {
|
||||
L.latLng = function (a, b, c) {
|
||||
if (a instanceof L.LatLng) {
|
||||
return a;
|
||||
}
|
||||
@ -70,11 +70,11 @@ L.latLng = function (a, b) {
|
||||
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.lat, 'lng' in a ? a.lng : a.lon, a.alt);
|
||||
}
|
||||
if (b === undefined) {
|
||||
return null;
|
||||
}
|
||||
return new L.LatLng(a, b);
|
||||
return new L.LatLng(a, b, c);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user