diff --git a/spec/suites/geo/LatLngSpec.js b/spec/suites/geo/LatLngSpec.js index 1c050df0..bca6c31c 100644 --- a/spec/suites/geo/LatLngSpec.js +++ b/spec/suites/geo/LatLngSpec.js @@ -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)); + }); }); }); diff --git a/src/geo/LatLng.js b/src/geo/LatLng.js index f56de668..0e451597 100644 --- a/src/geo/LatLng.js +++ b/src/geo/LatLng.js @@ -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); };