Vue中引入SuperMap超图

项目需要引入超图,再次将引入方式记录如下:
首先使用命令安装超图依赖插件:

npm install @supermap/vue-iclient --save

安装成功后进行全局引入,也可以局部页面引入,如下:
main.js引入

import VueiClient from '@supermap/vue-iclient';
Vue.use(VueiClient);

引入成功后进行加载超图,如下

<template>
	<div id="iGisMap">
    </div>
</template>

<script>
import { XYZ as XYZSource, Vector as VectorSource } from 'ol/source';
import Vector from 'ol/source/Vector.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import {bbox} from 'ol/loadingstrategy.js';
import 'ol/ol.css'
import { Map, View } from 'ol'
import Point from 'ol/geom/Point'
import TileLayer from 'ol/layer/Tile'
import { TileSuperMapRest } from '@supermap/iclient-ol'
import Feature from 'ol/Feature'
import { Style, Icon } from 'ol/style'
import Draw from 'ol/interaction/Draw'
import VectorLayer from 'ol/layer/Vector'
import Overlay from 'ol/Overlay'
export default {
	data() {
	 return {
      map:null,
      pointSource:null,
      pointLayer:null,
      feature:null,
      featureStyle:null,
      popupLayer: null,
	},
	created() {},
	watch: {},
	computed: {},
	mounted() {
      this.initMap()	
	},
	methods: {
	 initMap(){
      let url = "https://iserver.supermap.io/iserver/services/map-world/rest/maps/World";
      // 初始化地图信息
      this.mapObj = new window.iGis.GisMap()
      this.map = new Map({
          target: 'iGisMap',//对应div容器的id
          view: new View({
              center: [0, 0],//地图中心
              zoom: 18,//缩放层级
              projection: 'EPSG:4326'//坐标系
          })
      });

      // 添加图层
      let layer = new TileLayer({
          source: new TileSuperMapRest({
              url: url,//地图服务地址
              wrapX: true//是否在地图水平坐标轴上重复
          }),
          projection: 'EPSG:4326'//坐标系
      });

      this.map.addLayer(layer);//添加图层到地图
      setTimeout(()=>{
        this.map.updateSize(); //地图适配div容器
      },100)
    }
</script>
<style>
</style>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时间的情敌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值