问题描述
我正在尝试获取在我的本地笔记本电脑安装的 Geoserver 2.19.1 中显示为预安装的 topp:states 层的美国连续地图。我希望它在本地主机端口上显示为矢量图层。我实际上是从 https://openlayers.org/en/latest/examples/vector-wfs.html 处的 openlayers 示例开始的,并让该示例运行良好,在 http://localhost:1234 上看起来应该如此,但对于其他层,取自外部网站。通过一些努力,我发现了我希望为从 localhost:8080 获得的 Geoserver topp:states 层工作所需的修改,但我似乎无法让它出现在 localhost:1234
import 'ol/ol.css';
import GeoJSON from 'ol/format/GeoJSON';
import Map from 'ol/Map';
import VectorSource from 'ol/source/Vector';
import View from 'ol/View';
import {stroke,Style} from 'ol/style';
import {Vector as VectorLayer} from 'ol/layer';
import {bBox as bBoxStrategy} from 'ol/loadingstrategy';
var vectorSource = new VectorSource({
format: new GeoJSON(),url: 'http://localhost:8080/geoserver/wfs?service=WFS&' +
'version=1.1.0&request=GetFeature&typename=topp:states&'+
'outputFormat=application/json&srsname=epsg:3857&' +
'bBox=24.9,-124.8,49.5,-66.0',});
var vector = new VectorLayer({
source: vectorSource,style: new Style({
stroke: new stroke({
color: 'rgba(0,1.0)',width: 2,}),});
var map = new Map({
layers: [vector],target: document.getElementById('map'),view: new View({
center: [-10000000,4500000.0],zoom: 4,});
任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)