0

how to add a feature to a exist layer on map , openlayers-7 this is my code : I defined a vector Layer named myJson and i want to add a Point to this layer in code how can i achieve that ?

const myJson = new VectorLayer({
  source: new VectorSource({
    format: new GeoJSON(),
    url: 'geo.json'
  })
})

map.addLayer(myJson);
 const P1= new Feature (new Point(coordinate));
        myJson.addFeature(P1);
  • 1
    The feature must be added to the layer's source `myJson.getSource().addFeature(P1);` – Mike Feb 08 '23 at 14:57

0 Answers0