我正在尝试从 Vue.js 中的本地主机 Geoserver 读取 WMS 层。我在与 vue.js 不同的端口上运行 Geoserver。
我应该如何在 Vue JS 中加载我的 WMS 层,如下例所示:https ://vuelayers.github.io/#/docs/component/tile-layer
<template>
<vl-map :load-tiles-while-animating="true" :load-tiles-while-interacting="true" data-projection="EPSG:4326" style="height: 400px">
<vl-view :zoom.sync="zoom" :center.sync="center" :rotation.sync="rotation"></vl-view>
<vl-layer-tile>
<vl-source-sputnik></vl-source-sputnik>
</vl-layer-tile>
<vl-layer-tile id="wmts">
<vl-source-wmts :attributions="attribution" :url="url" :layer-name="layerName" :matrix-set="matrixSet" :format="format"
:style-name="styleName"></vl-source-wmts>
</vl-layer-tile>
</vl-map>
</template>
//////////////////////////////// For WMS SOURCES
<script>
export default {
data () {
return {
zoom: 4,
center: [50, 40],
rotation: 0,
cmp: 'vl-source-wms',
url: 'http://localhost:8081/geoserver/cite/wms',
layers: 'cite:vnm_polbnda_adm3_2014_pdc',
extParams: { TILED: true },
serverType: 'geoserver',
}
},
}
</script>
在我的浏览器中: CORS 策略已阻止从源“ http://localhost:3000 ”访问“ http://192.168.1.23:3000/sockjs-node/info?t=1578388235952 ”处的 XMLHttpRequest:值当请求的凭据模式为“包含”时,响应中的“Access-Control-Allow-Origin”标头不能是通配符“*”。XMLHttpRequest 发起的请求的凭证模式由 withCredentials 属性控制。