API DOCUMENTATION

FitBounds

Obtain two coordinate values, north-eastern(ne) and south-western(ne) longitude and latitude, and move them to the center coordinated of the range.

mapInstance.fitBounds( bounds , opt );

 

Parameter
Required Parameter Description
bounds Center these bounds in the viewport and use the highest zoom level up to and including Map

Optional Parameter Description
padding The amount of padding in pixels to add to the given bounds.
linear If true , the map transitions using Map#easeTo . If false , the map transitions using Map#flyTo .
maxZoom The maximum zoom level to allow when the map view transitions to the specified bounds.

 

Example
let fit = {
        sw: {lat: 37.457464, lng: 126.899302},
        ne: {lat: 37.645804, lng: 127.161728}
    }
let opt = {
       top: 10,
       bottom: 10,
       right: 10,
       left: 10
    }
 map.fitBounds(fit,opt);

getBounds

Gets the two coordinate value(north-east, south-west) longitude/latitude) set in ‘fitBounds’.

mapInstance.getBounds( );

 

Return

ne / sw coordinate value of LngLatBounds

 

Example
mapInstance.getBounds()
return : ne : {lat: 37.645804, lng: 127.161728}
sw : {lat: 37.457464, lng: 126.899302}