网页中leaflet地图怎么居中显示?
如题,我网页在使用是leaflet地图,底图使用的是mapbox。现在我想要让地图以太平洋为中心显示,并且上下左右都有边界,不能超过图中的红框。
我使用过设置边线,但是无效或者只能固定到一个区域,不能拖动了
var corner1 = L.latLng(-174.037881,81.331765) //设置左上角经纬度
var corner2 = L.latLng(-122.527145,-80.715235) //设置右下点经纬度
var bounds = L.latLngBounds(corner1, corner2) //构建视图限制范围
mymap.panInsideBounds(bounds)
leaflet的版本是1.8.0