Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

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%


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...