Sha256: 4beb69015c8100bc26a55176a2e8858ac3eabe32dafadc8f2030b020a05227af
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
/* * L.LatLng represents a geographical point with latitude and longitude coordinates. */ L.LatLng = function (lat, lng, alt) { if (isNaN(lat) || isNaN(lng)) { throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')'); } this.lat = +lat; this.lng = +lng; if (alt !== undefined) { this.alt = +alt; } }; L.LatLng.prototype = { equals: function (obj, maxMargin) { if (!obj) { return false; } obj = L.latLng(obj); var margin = Math.max( Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)); return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin); }, toString: function (precision) { return 'LatLng(' + L.Util.formatNum(this.lat, precision) + ', ' + L.Util.formatNum(this.lng, precision) + ')'; }, distanceTo: function (other) { return L.CRS.Earth.distance(this, L.latLng(other)); } }; // constructs LatLng with different signatures // (LatLng) or ([Number, Number]) or (Number, Number) or (Object) L.latLng = function (a, b) { if (a instanceof L.LatLng) { return a; } if (L.Util.isArray(a) && typeof a[0] !== 'object') { if (a.length === 3) { return new L.LatLng(a[0], a[1], a[2]); } return new L.LatLng(a[0], a[1]); } 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); };
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
leaflet-js-0.8.dev2 | lib/leaflet/src/geo/LatLng.js |