LatLngBounds for Mapbox.js to fetch all corners lat long of map


Represents a rectangular geographical area on a map.
var southWest = L.latLng(40.712, -74.227),   northEast = L.latLng(40.774, -74.125),   bounds = L.latLngBounds(southWest, northEast);
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:
map.fitBounds([   [40.712, -74.227],   [40.774, -74.125]  ]);

Creation

FactoryDescription
L.latLngBounds( <LatLngsouthWest, <LatLngnorthEast )Creates a latLngBounds object by defining south-west and north-east corners of the rectangle.
L.latLngBounds( <LatLng[]> latlngs ) Creates a LatLngBounds object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with fitBounds.

Methods

MethodReturnsDescription
extend( <LatLng|LatLngBoundslatlng ) thisExtends the bounds to contain the given point or bounds.
getSouthWest()LatLngReturns the south-west point of the bounds.
getNorthEast()LatLngReturns the north-east point of the bounds.
getNorthWest()LatLngReturns the north-west point of the bounds.
getSouthEast()LatLngReturns the south-east point of the bounds.
getWest()NumberReturns the west longitude of the bounds.
getSouth()NumberReturns the south latitude of the bounds.
getEast()NumberReturns the east longitude of the bounds.
getNorth()NumberReturns the north latitude of the bounds.
getCenter()LatLngReturns the center point of the bounds.
contains( <LatLngBoundsotherBounds ) BooleanReturns true if the rectangle contains the given one.
contains( <LatLnglatlng ) BooleanReturns true if the rectangle contains the given point.
intersects( <LatLngBoundsotherBounds ) BooleanReturns true if the rectangle intersects the given bounds.
equals( <LatLngBoundsotherBounds ) BooleanReturns true if the rectangle is equivalent (within a small margin of error) to the given bounds.
toBBoxString()StringReturns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat'format. Useful for sending requests to web services that return geo data.
pad( <Number> bufferRatio ) LatLngBoundsReturns bigger bounds created by extending the current bounds by a given percentage in each direction.
isValid() BooleanReturns true if the bounds are properly initialized.

No comments:

Post a Comment