antv L7 要怎么设置地图绘制范围的大小。

新手上路,请多包涵

问题描述

之前用过antv g2 的都是在new Chart里设置width和height限定绘制范围大小,L7里这样写好像不对,请问要怎么设置呢不想让它自己延展至100%

问题出现的平台版本及自己尝试过哪些方法

"@antv/l7": "^2.3.1"

相关代码

const scene = new Scene({

  id: 'map',
  resizeEnable: true,
  logoVisible: false,
  autoFit: true,
  height: 200 ,
  width: 200,
  map: new Mapbox({
    pitch: 40,
    style: {
      version: 8,
      sprite: 'https://lzxue.github.io/font-glyphs/sprite/sprite',
      glyphs:
        'https://gw.alipayobjects.com/os/antvdemo/assets/mapbox/glyphs/{fontstack}/{range}.pbf',
      sources: {},
      layers: [
        {
          id: 'background',
          type: 'background',
          autoFit: true,
          width: 200,
          height: 200,
        }
      ],
      height: 200 ,
      width: 200,
    },
    height: 200 ,
      width: 200,
    center: [3.438, 40.16797],
    zoom: 0.51329
  }),
  style: {
    height: 200 ,
    width: 200,
  }
});

你期待的结果是什么?实际看到的错误信息又是什么?

怎么限制绘制范围,不想让它自己延展至100%

阅读 6.3k
2 个回答

在的id= "map" 的容器上 添加样式 justify-content: center; position: relative 并设置宽高即可 亲测有效

新手上路,请多包涵

可以在这个地图的外部添加一个div,,给这个div设置宽高,如果想让地图显示某一部分的区域,在new的时候给center一个经纬度,再加上zoom添加缩放值就可以。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题