coinhndp
coinhndp

Reputation: 2481

React google map getBounds

I use react-google-maps library and when I get the boundaries through function getBounds. I got the object which looks like this

_.Kc {f: Jc, b: Fc}
 b:Fc {b: -69.44550556640627, f: -69.37409443359377}
 f:Jc {b: 5.843139027557267, f: 5.958055017316458}
 __proto__:Object

And I need the Bottom left boundary (lat, lng) and Top right boundary (lat, lng). Could you show me what is the number b and f? which one is bottom left boundary lat, bottom left boundary lng, top right boundary lat, top right boundary lng. I cant find any documentation

Upvotes: 3

Views: 7468

Answers (1)

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59358

Map.getBounds method returns LatLngBounds value which

represents a rectangle in geographical coordinates, including one that crosses the 180 degrees longitudinal meridian

Use

Example:

    onMapIdle={() => {
        let ne = this.map.getBounds().getNorthEast();
        let sw = this.map.getBounds().getSouthWest();
        console.log(ne.lat() + ";" + ne.lng());
        console.log(sw.lat() + ";" + sw.lng());
      }}

Here is a demo for your reference

Upvotes: 6

Related Questions