lib/leaflet/src/geo/LatLng.js in leaflet-js-0.6.beta4 vs lib/leaflet/src/geo/LatLng.js in leaflet-js-0.7.0
- old
+ new
@@ -1,19 +1,23 @@
/*
* L.LatLng represents a geographical point with latitude and longitude coordinates.
*/
-L.LatLng = function (rawLat, rawLng) { // (Number, Number)
- var lat = parseFloat(rawLat),
- lng = parseFloat(rawLng);
+L.LatLng = function (lat, lng, alt) { // (Number, Number, Number)
+ lat = parseFloat(lat);
+ lng = parseFloat(lng);
if (isNaN(lat) || isNaN(lng)) {
- throw new Error('Invalid LatLng object: (' + rawLat + ', ' + rawLng + ')');
+ throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
}
this.lat = lat;
this.lng = lng;
+
+ if (alt !== undefined) {
+ this.alt = parseFloat(alt);
+ }
};
L.extend(L.LatLng, {
DEG_TO_RAD: Math.PI / 180,
RAD_TO_DEG: 180 / Math.PI,
@@ -73,16 +77,23 @@
L.latLng = function (a, b) { // (LatLng) or ([Number, Number]) or (Number, Number)
if (a instanceof L.LatLng) {
return a;
}
if (L.Util.isArray(a)) {
- return new L.LatLng(a[0], a[1]);
+ if (typeof a[0] === 'number' || typeof a[0] === 'string') {
+ return new L.LatLng(a[0], a[1], a[2]);
+ } else {
+ return null;
+ }
}
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);
+ }
+ if (b === undefined) {
+ return null;
}
return new L.LatLng(a, b);
};