Leaflet Get Bounds w / only top padding

时间:2018-05-01 01:32:09

标签: leaflet react-leaflet

我在调用getBounds()时知道pad方法,但有没有办法可以在地图顶部指定填充?

例如,这样可以平等地填充所有方面:

const box = map.getBounds().pad(-.2).toBBoxString()

我基本上希望在Leaflet中做Mapbox做here

1 个答案:

答案 0 :(得分:1)

只是spitballing。

# Expand the northern boundary (and the others) to the correct size
tmp_expanded = map.getBounds().pad( -0.2 );
# Get a coordinate along the northern boundary
northern_coord = tmp_expanded.getNorthEast();
# Expand the northern boundary only by encompassing the northern coord
box = map.getBounds().extend( northern_coord ).toBBoxString();

它不漂亮,但它可以解决问题。