ol.layer.Vector通过geojson不完整显示地图图层?

时间:2018-01-08 10:03:39

标签: javascript openlayers openlayers-3 geojson geoserver

我所遇到的:

我使用Google Map作为底图,GeoServer作为GIS服务器,提供WMS和WFS服务。

通过WMS正确显示了图层。但是,当我尝试通过GeoJSON显示它时,它没有完全显示。 “不完整”意味着:大约一半的多边形被展示,但其他多边形没有。

我该怎么办?

我是GIS的新手。我尝试了gsojson链接,发现GeoServer确实返回了一个正确的JSON字符串,大小超过200kB ......

有谁能知道我遇到的错误是什么?或者告诉我如何解决它?

提前致谢!

数据

我的GeoJSON数据是这样的:

{
"type": "FeatureCollection", 
"totalFeatures": 9, 
"features": [
    {
        "type": "Feature", 
        "id": "the_layer.1", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.2", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.3", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.4", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ], 
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.5", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": []
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.6", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.7", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.8", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }, 
    {
        "type": "Feature", 
        "id": "the_layer.9", 
        "geometry": {
            "type": "MultiPolygon", 
            "coordinates": [
                [
                    []
                ]
            ]
        }, 
        "geometry_name": "the_geom", 
        "properties": {
            "ID": "0", 
            "SYMBOL": "", 
            "NAME": ""
        }
    }
], 
"crs": {
    "type": "name", 
    "properties": {
        "name": "urn:ogc:def:crs:EPSG::4326"
    }
}
}}

其他信息

GeoServer版本:2.12.1

OpenLayer3,v4.6.4

我的WMS和WFS服务是从.shp文件生成的,该文件由我们的客户提供,并且是保密的。

这是我的openlayers代码:

  var drainageJson = new ol.layer.Vector({
    visible: true,
    source: new ol.source.Vector({
      format: new ol.format.GeoJSON(),
      projection: 'EPSG:4326',
      url: 'http://127.0.0.1/geoserver/cite/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=cite:the_layer&maxFeatures=50&outputFormat=application/json',
    })
  });

根据@Ian Turton的建议,我尝试使用QGIS访问WFS源,但QGIS显示:“图层the_layer:下载图层引用的功能:the_layer失败或部分失败:解析GetFeature响应时出错:错误:第1行,第8522行上的格式不正确(无效令牌)。您可以尝试使用F5重新加载图层。

然后我提高了GeoServer的日志记录级别,得到了the log file

0 个答案:

没有答案