Openlayers 3 从geoserver加载为GeoJSON时,OL3中未显示WFS层

Openlayers 3 从geoserver加载为GeoJSON时,OL3中未显示WFS层,openlayers-3,Openlayers 3,我正在尝试将我的图层作为我的OL3应用程序中的WFS图层从Geoserver加载 以下是我创建WFS层的代码: var vectorSource = new ol.source.Vector({ format: new ol.format.GeoJSON(), url: function(extent, resolution, projection) { return 'http://localhost:8080/geoserver/wfs?service=WFS&' +

我正在尝试将我的图层作为我的OL3应用程序中的WFS图层从Geoserver加载

以下是我创建WFS层的代码:

var vectorSource = new ol.source.Vector({
  format: new ol.format.GeoJSON(),
  url: function(extent, resolution, projection) {
    return 'http://localhost:8080/geoserver/wfs?service=WFS&' +
        'version=1.0.0&request=GetFeature&typename=main:Building_WGS&' +
        'outputFormat=application/json&srsname=EPSG:4326&';
  },
  strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
  }))
});


var vector1 = new ol.layer.Vector({
  source: vectorSource,
  style: new ol.style.Style({
    stroke: new ol.style.Stroke({
      color: 'rgba(0, 0, 255, 1.0)',
      width: 2
    })
  })
});
要使我的代码完整,以下是我创建map对象的代码:

var centerpos = [84.2, 28.2];
var newpos = ol.proj.transform(centerpos,'EPSG:4326','EPSG:900913');
var maxExtent = [80.05844110726194,26.34796712822462,88.2015218371264,30.44742963310623];

var map = new ol.Map({
      layers: [baseLayerOSM, vector1],
      target: 'map',
      //controls: [new CustomControl()],
      view: new ol.View({
        extent:ol.proj.transformExtent(maxExtent, 'EPSG:4326', 'EPSG:900913'),
        projection : 'EPSG:900913', // OSM projection
        center : newpos,
        minZoom:7,
        zoom: 7
      })
    });
我可以在地图中看到OSM层。但是我看不到建筑层。我在geoserver中有一个主工作区

当我复制URL时

'http://localhost:8080/geoserver/wfs?service=WFS&' +
            'version=1.0.0&request=GetFeature&typename=main:Building_WGS&' +
            'outputFormat=application/json&srsname=EPSG:4326&';
我可以看到JSON的内容

有人能告诉我我的代码哪里做错了吗

我甚至尝试添加crossOrigin:“匿名”,但这也没用

请帮忙


AJ

在使用地图时检查开发人员工具。有错误信息吗?有没有失败的请求?没有错误消息,或者我在开发工具上没有检查过任何内容?源代码中是否添加了任何功能?没有,我只是尝试将我的层视为向量层。我什么都不做。我认为代码应该可以正常工作,但由于某些原因,我看不到层,并且没有错误消息。是否有其他方法添加向量层?