Renames L.LatLng property .altitude to .alt

This commit is contained in:
Hans Kristian Flaatten 2013-07-03 15:44:57 +02:00
parent 46885de00d
commit 8e98e52b88
3 changed files with 8 additions and 8 deletions

View File

@ -18,15 +18,15 @@ describe('LatLng', function() {
it ('does not set altitude if undefined', function () { it ('does not set altitude if undefined', function () {
var a = new L.LatLng(25, 74); var a = new L.LatLng(25, 74);
expect(typeof a.altitude).to.eql('undefined'); expect(typeof a.alt).to.eql('undefined');
}); });
it ('sets altitude', function () { it ('sets altitude', function () {
var a = new L.LatLng(25, 74, 50); var a = new L.LatLng(25, 74, 50);
expect(a.altitude).to.eql(50); expect(a.alt).to.eql(50);
var b = new L.LatLng(-25, -74, -50); var b = new L.LatLng(-25, -74, -50);
expect(b.altitude).to.eql(-50); expect(b.alt).to.eql(-50);
}); });
}); });

View File

@ -2,7 +2,7 @@
* L.LatLng represents a geographical point with latitude and longitude coordinates. * L.LatLng represents a geographical point with latitude and longitude coordinates.
*/ */
L.LatLng = function (rawLat, rawLng, rawAltitude) { // (Number, Number, Number) L.LatLng = function (rawLat, rawLng, rawAlt) { // (Number, Number, Number)
var lat = parseFloat(rawLat), var lat = parseFloat(rawLat),
lng = parseFloat(rawLng); lng = parseFloat(rawLng);
@ -13,8 +13,8 @@ L.LatLng = function (rawLat, rawLng, rawAltitude) { // (Number, Number, Number)
this.lat = lat; this.lat = lat;
this.lng = lng; this.lng = lng;
if (typeof rawAltitude !== 'undefined') { if (typeof rawAlt !== 'undefined') {
this.altitude = parseFloat(rawAltitude); this.alt = parseFloat(rawAlt);
} }
}; };

View File

@ -147,10 +147,10 @@ L.extend(L.GeoJSON, {
}, },
latLngToCoords: function (latLng) { latLngToCoords: function (latLng) {
if (typeof latLng.altitude === 'undefined') { if (typeof latLng.alt === 'undefined') {
return [latLng.lng, latLng.lat]; return [latLng.lng, latLng.lat];
} else { } else {
return [latLng.lng, latLng.lat, latLng.altitude]; return [latLng.lng, latLng.lat, latLng.alt];
} }
}, },