在openlayers中调用iserver发布的内容,地图出不来,只能显示放大缩小按钮。代码如下:
<template>
<div class="supMap-box">
<div id="map" style="width: 1000px; height:1000px">
<!-- <img src="./images/u9.png"> -->
</div>
</div>
</template>
<script>
import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
// import ImageLayer from 'ol/layer/Image';
import { TileSuperMapRest } from '@supermap/iclient-ol';
export default {
name: "Index",
data() {
return {
map:'',
SupMap:null
};
},
mounted() {
this.initMap()
},
methods:{
initMap(){
var supermapurl='http://localhost:8090/iserver/services/map-HanJiangLiuYuDiTu-2/rest/maps/%E6%B1%89%E6%B1%9F%E6%B5%81%E5%9F%9F.ol3'
// var projection=new projection({
// code:'EPSG:4490',
// units:'m',
// axisOrientation: 'enu',
// global: false
// })
// addProjection(projection)
var jcdt=new TileLayer({
source:new TileSuperMapRest({
url:supermapurl,
wrapx:true
}),
projection:'EPSG:4326'
})
const map=new Map({
Layers:jcdt,
target:'map',
view:new View({
center:[112.1,32],
zoom:6,
projection:'EPSG:4326'
})
});
// window.map = map;
// this.map = map;
}
}
};
</script>
<style scoped lang="scss">
</style>