如何在Mapbox构造函数中添加边界和填充?
使用map.fitBounds(bounds, {padding: 100})
,可以在设置边界时添加填充,确保您的标记(“边界”所基于的)都很好地显示在地图的可见部分。 我想在构造函数中实现相同的目标,其中可以像这样设置边界:
var map = new mapboxgl.Map({
container: 'MapPanel',
style: 'mapbox://styles/mapbox/streets-v11',
bounds: bounds});
我找不到包含填充的方法 - 有人知道怎么做吗?
更新: 谢谢@Steve - 只需确认您的解决方案就可以解决我的问题。
With map.fitBounds(bounds, {padding: 100})
, it is possible to add padding while setting the bounds making sure your markers (on which 'bounds' are based) are all nicely shown inside the viewable part of the map.
I'd like to achive the same in the constructor where the bounds can be set like this:
var map = new mapboxgl.Map({
container: 'MapPanel',
style: 'mapbox://styles/mapbox/streets-v11',
bounds: bounds});
I can't find a way to include the padding - does anyone know how?
Update:
Thanks @Steve - just confirming your solution solves my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是
fitBoundSoptions
参数是:这样使用:
That's what the
fitBoundsOptions
parameter is for:Use it like this: