Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps JS API - get the north west & south east bounds [duplicate]

I'm working with google maps javascript API and I need to get the bounds of the current viewport.
I tried to use map.getBounds(); then getNorthEast()... etc. but the problem is that I need the North West, and the South East coordinates, not North East and South West.

Any way to get those bounds or "convert" the bounds that the API gives me to get North West and South East ?

Thank you

like image 998
mgul Avatar asked Jun 12 '16 12:06

mgul


1 Answers

In the sample below you can extract the coords for North, East, South, and West

and you can use North West , South East

    aNorth  =   map.getBounds().getNorthEast().lat();   
    aEast   =   map.getBounds().getNorthEast().lng();
    aSouth  =   map.getBounds().getSouthWest().lat();   
    aWest   =   map.getBounds().getSouthWest().lng();   
like image 103
ScaisEdge Avatar answered Nov 15 '22 08:11

ScaisEdge