Skip to content

Commit

Permalink
Improve LatLng docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Mar 18, 2015
1 parent c2211cd commit 7740a35
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions js/geo/lat_lng.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ var wrap = require('../util/util').wrap;
/**
* Create a latitude, longitude object from a given latitude and longitude pair in degrees.
*
* @class mapboxgl.LatLng
* @class LatLng
* @classdesc A representation of a latitude and longitude point, in degrees.
* @param {Number} latitude
* @param {Number} longitude
* @returns {mapboxgl.LatLng} `this`
* @param {number} latitude
* @param {number} longitude
* @example
* var latlng = new mapboxgl.LatLng(37.76, -122.44);
*
Expand All @@ -24,18 +23,28 @@ function LatLng(lat, lng) {
this.lng = +lng;
}

/**
* Return a new `LatLng` object whose longitude is wrapped to the range (-180, 180).
*
* @returns {LatLng}
*/
LatLng.prototype.wrap = function () {
return new LatLng(this.lat, wrap(this.lng, -180, 180));
};

// constructs LatLng from an array if necessary

LatLng.convert = function (a) {
if (a instanceof LatLng) {
return a;
/**
* Convert an array to a `LatLng` object, or return an existing `LatLng` object
* unchanged.
*
* @param {Array<number>|LatLng} input `input` to convert
* @returns {LatLng}
*/
LatLng.convert = function (input) {
if (input instanceof LatLng) {
return input;
}
if (Array.isArray(a)) {
return new LatLng(a[0], a[1]);
if (Array.isArray(input)) {
return new LatLng(input[0], input[1]);
}
return a;
return input;
};

0 comments on commit 7740a35

Please sign in to comment.