LatLngBounds | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Nested Classes | Inherited Constants | Fields | Ctors | Methods | Inherited Methods | [Expand All]
public final class

# LatLngBounds

extends Object
implements SafeParcelable

java.lang.Object
↳ | com.google.android.gms.maps.model.LatLngBounds

## Class Overview

An immutable class representing a latitude/longitude aligned rectangle.

## Summary

Nested Classes
class | LatLngBounds.Builder | This is a builder that is able to create a minimum bound based on a set of LatLng points.

[Expand] Inherited Constants
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |
From interface com.google.android.gms.common.internal.safeparcel.SafeParcelable
String | NULL |

Fields
public static final LatLngBoundsCreator | CREATOR |
public final LatLng | northeast | Northeast corner of the bound.
public final LatLng | southwest | Southwest corner of the bound.

Public Constructors
| LatLngBounds(LatLng southwest, LatLng northeast) Creates a new bounds based on a southwest and a northeast corner.

Public Methods
static LatLngBounds.Builder | builder() Creates a new builder.
boolean | contains(LatLng point) Returns whether this contains the given `LatLng`.
int | describeContents()
boolean | equals(Object o)
LatLng | getCenter() Returns the center of this LatLngBounds.
int | hashCode()
LatLngBounds | including(LatLng point) Returns a new `LatLngBounds` that extends this LatLngBounds to include the given `LatLng`.
String | toString()
void | writeToParcel(Parcel out, int flags)

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Fields

#### public static final LatLngBoundsCreator CREATOR

#### public final LatLng northeast

Northeast corner of the bound.

#### public final LatLng southwest

Southwest corner of the bound.

## Public Constructors

#### public LatLngBounds (LatLng southwest, LatLng northeast)

Creates a new bounds based on a southwest and a northeast corner.

The bounds conceptually includes all points where:

- the latitude is in the range [northeast.latitude, southwest.latitude];
- the longitude is in the range [southwest.longtitude, northeast.longitude] if southwest.longtitude ≤ northeast.longitude; and
- the longitude is in the range [southwest.longitude, 180) ∪ [-180, northeast.longitude] if southwest.longtitude > northeast.longitude.

##### Parameters

southwest | southwest corner
northeast | northeast corner

##### Throws

IllegalArgumentException | if the latitude of the northeast corner is below the latitude of the southwest corner.

## Public Methods

#### public static LatLngBounds.Builder builder ()

Creates a new builder.

#### public boolean contains (LatLng point)

Returns whether this contains the given `LatLng`.

##### Parameters

point | the `LatLng` to test

##### Returns

- `true` if this contains the given point; `false` if not.

#### public int describeContents ()

#### public boolean equals (Object o)

#### public LatLng getCenter ()

Returns the center of this LatLngBounds. The center is simply the average of the coordinates (taking into account if it crosses the antimeridian). This is approximately the geographical center (it would be exact if the Earth were a perfect sphere). It will not necessarily be the center of the rectangle as drawn on the map due to the Mercator projection.

##### Returns

- A `LatLng` that is the center of the LatLngBounds.

#### public int hashCode ()

#### public LatLngBounds including (LatLng point)

Returns a new `LatLngBounds` that extends this LatLngBounds to include the given `LatLng`. This will return the smallest LatLngBounds that contains both this and the extra point.

In particular, it will consider extending the bounds both in the eastward and westward directions (one of which may cross the antimeridian) and choose the smaller of the two. In the case that both directions result in a LatLngBounds of the same size, this will extend it in the eastward direction.

##### Parameters

point | a `LatLng` to be included in the new bounds

##### Returns

- A new `LatLngBounds` that contains this and the extra point.

#### public String toString ()

#### public void writeToParcel (Parcel out, int flags)