为什么没有正确显示MultilineString图层

时间:2018-05-14 12:48:53

标签: openlayers

onComponentDidMount,我运行一个函数:

async mountPanoramasTiles() {
await this.fetchPanoramTracks();
this.drawRoadsLayer(this.panoramasTracksLayer);

This.drawRoadsLayer是下一个:

drawRoadsLayer(geoJSON) {
const { map, point } = this.props;

const geoVector = new ol.source.Vector({
  features: new ol.format.GeoJSON().readFeatures(geoJSON)
});

const tilesStyle = new ol.style.Style({
  stroke: new ol.style.Stroke({
    color: "blue",
    width: 1
  })
});

this.panoramasTracksLayer = new ol.layer.Vector({
  source: geoVector,
  style: tilesStyle
});
map.addLayer(this.panoramasTracksLayer);

我有来自服务器的响应,其中包含以下信息:

{"type":"Feature","id":"default_pano_shape.1","geometry":{"type":"MultiLineString","coordinates":[[[4162645.3515,7525239.799],[4162632.2158,7525249.9675],[4162622.9094,7525261.4838],[4162619.9373,7525275.8742],[4162622.5198,7525293.0397],[4162630.8019,7525307.0339],[4162644.0935,7525316.8061],[4162657.6077,7525321.504],[4162674.4211,7525324.5403]]]},"geometry_name":"geom","properties":{"objectid":1,"id":0,"shape_leng":127.622459436989288}

我使用geoJSON类型的数据,geoJSON和地图的所有格式都是相同的(EPSG:3857),但我没有长行(道路),而是看到短截距。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

geojson数据中存在错误。将代码粘贴到www.geojson.io,它将指导您何时缺少一些大括号,数组深度级别等。 祝你好运!