添加Openlayers点以映射为单个图层

时间:2017-08-04 21:12:27

标签: javascript geospatial openlayers

  plotBaseLayer (data) {
    this.setState({ data: data })

    const baseFeatures = []
    let baseLayer = Object()

    Object.keys(data.features).forEach((key) => {
      const basePoints = new olFeature({
        geometry: new olGeomPoint(olProj.transform(
          [data.features[key].geometry.coordinates[0], data.features[key].geometry.coordinates[1]],
          'EPSG:4326', MapHandler.map.getView().getProjection().getCode())
        )
      })

      baseFeatures.push(basePoints)
      const vectorSource = new olSourceVector()

      vectorSource.addFeature(basePoints)
      baseLayer = new olLayerVector({ source: vectorSource })

      this.map.addLayer(baseLayer)
    })
  }

目前,我正在为要素添加每个点,并将该要素单独添加到地图中作为单个图层。我如何构建我的代码和/或使用替代的Openlayers功能,以便将所有点绘制为单个图层?谢谢你的期待!

1 个答案:

答案 0 :(得分:1)

这可能有用吗?

NullPointerException