Changed of L.LatLngBounds arg names to corners (#5059)

as proposed in a recent issue.
This change should not affect the code, it is only for consistency with docstrings.
docstrings: replaced southWest and northEast argument names by corner1 and corner2, to try to prevent confusion that Leaflet will keep these corners at those places, whereas it actually "re-orders" them to keep lowest values West-most / South-most, as if they were just corners.
This commit is contained in:
ghybs 2016-10-28 11:38:09 +04:00 committed by Iván Sánchez Ortega
parent 0b5c12fd65
commit edbcff4386

View File

@ -7,9 +7,9 @@
* @example
*
* ```js
* var southWest = L.latLng(40.712, -74.227),
* northEast = L.latLng(40.774, -74.125),
* bounds = L.latLngBounds(southWest, northEast);
* var corner1 = L.latLng(40.712, -74.227),
* corner2 = L.latLng(40.774, -74.125),
* bounds = L.latLngBounds(corner1, corner2);
* ```
*
* All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:
@ -20,12 +20,14 @@
* [40.774, -74.125]
* ]);
* ```
*
* Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.
*/
L.LatLngBounds = function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[])
if (!southWest) { return; }
L.LatLngBounds = function (corner1, corner2) { // (LatLng, LatLng) or (LatLng[])
if (!corner1) { return; }
var latlngs = northEast ? [southWest, northEast] : southWest;
var latlngs = corner2 ? [corner1, corner2] : corner1;
for (var i = 0, len = latlngs.length; i < len; i++) {
this.extend(latlngs[i]);
@ -227,8 +229,8 @@ L.LatLngBounds.prototype = {
// TODO International date line?
// @factory L.latLngBounds(southWest: LatLng, northEast: LatLng)
// Creates a `LatLngBounds` object by defining south-west and north-east corners of the rectangle.
// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)
// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.
// @alternative
// @factory L.latLngBounds(latlngs: LatLng[])