添加 Openlayers 点以映射为单层

Add Openlayers points to map as single layer

  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)
    })
  }

目前我正在将每个点添加到一个要素,并将该要素作为单独的图层单独添加到地图。我如何构建我的代码 and/or 利用替代的 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 ol.source.Vector({
       features: baseFeatures
    });


    baseLayer = new olLayerVector({
            source: vectorSource
    })
    this.map.addLayer(baseLayer)
 }