Search code examples
google-mapsgoogle-maps-api-3google-geocodergoogle-geocoding-api

What are the northeast and southwest bounds in the Google Maps API?


What do these bounds signify ? Is it it some sort of approximation taken from different angles or directions ?


Solution

  • The north-east and south-west are for creating a rectangle. It constructs a rectangle from the points at its south-west and north-east corners. See LatLngBounds class.

    If this is still confusing, north-east and south-west are the top-right corner and the bottom-left corner of a rectangle respectively.

    It can be used like this:

    bounds: new google.maps.LatLngBounds(
        new google.maps.LatLng(33.671019, -116.254049),//south west
        new google.maps.LatLng(33.685424, -116.229930) //north east
    )
    

    A good sample would be location biasing in Autocomplete using bounds. If you add a bounds in autocomplete, it will create a rectangle using the south-west and north-east latlng and try to search within that rectangle only.

    It could also be used for literally drawing a rectangle in map. I have made a sample in JSBin for you. You can see there that I created a rectangle using bounds. I also plotted 2 markers pointing at the north-east and south-west.