openlayers,地图创建 初始化 天地图底图添加

    //ol引入 地图常用的 不用的可自行删除
    import { Map, View } from "ol";
    import XYZ from "ol/source/XYZ";
    import { Vector as VectorSource ,OSM,Stamen} from "ol/source";
    import { Tile as TileLayer, Vector as VectorLayer ,Tile} from "ol/layer";
    import {Icon,Style,Text,Fill,Stroke,} from "ol/style";
        this.vectorSource = new VectorSource({
            features: [],
        });
        this.tianditu = new TileLayer({
        name: "天地图影像图层",
        className: 'stamen',
        source:
          new XYZ({
                url: "http://t0.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=0c37299462312e175cab9628d29c7563", //0c37299462312e175cab9628d29c7563为天地图密钥每天限量刷新次数 次数达到会不显示该图层 可去天地图官自行创建
                wrapX: false,
              }),
          }),
        this.VectorLayer = new VectorLayer({
          source: this.vectorSource,
          style:new Style({
            fill: new Fill({
              color: 'rgba(0, 0, 0, 0)',
            }),
            stroke: new Stroke({
              color:'#099afa',
              width:2,
            }),
          }),
          zIndex: 9999,
        }),
        this.map = new Map({
          target: this.mapId,
          layers: [//需要加载的图层
            this.tianditu ,//天地图影像层
            this.VectorLayer
          ],
          view: new View({ //初次加载视角中心点
            center: [12325076.579397999, 2306279.9514405],
            // maxZoom: 17,
            // minZoom: 7,
            zoom: 14,
          }),
        });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值