Sami
Sami

Reputation: 477

Getting coordinates of a map's corners

I want to get coordinates of map's corners like shown in the image

enter image description here

Upvotes: 0

Views: 536

Answers (1)

duncan
duncan

Reputation: 31912

Use map.getBounds(). This returns a LatLngBounds object. From that you can then use getNorthEast() and getSouthWest() to get those corners. These aren't the ones you want though, so you'll have to do a little bit of logic to figure out the North West and South East parts. i.e. use the lat() of the NorthEast corner with the lon() of the SouthWest corner for the NorthWest coordinate, and the lon() of the NorthEast corner with the lat() of the SouthWest corner for the SouthEast coordinate.

Upvotes: 3

Related Questions