Skip to main content

I would like to callexport the features drawn on my own in the OpenLayers map and export them in the .geoJSONGeoJSON format.

So far everything is working apart from the "Properties"properties section, which keeps coming with nothing, asenter image description here you see below.

enter image description here

I would like to define something for every individual drawing I make on the map.

I found some nice approaches here:

Openlayers 3 draw set name

but it doesn't work in my code:

 var lineInteraction = new ol.interaction.Draw({ type: 'LineString', source: vectorLayer.getSource() }); lineInteraction.setActive(false); lineInteraction.on('drawend', onDrawend) { feature.setProperties({ 'id':1234, 'name': 'yourCustomName' }); console.log(feature, feature.getProperties()); }); 

Is it the OpenLayers library reason behind it? The aforementioned example refers to version 3.0.

My full JS fiddle is here: https://jsfiddle.net/fb9mtyz3/

I would like to call the features drawn on my own in the OpenLayers map and export them in the .geoJSON format.

So far everything is working apart from the "Properties" section, which keeps coming with nothing, asenter image description here you see below.

I would like to define something for every individual drawing I make on the map.

I found some nice approaches here:

Openlayers 3 draw set name

but it doesn't work in my code:

 var lineInteraction = new ol.interaction.Draw({ type: 'LineString', source: vectorLayer.getSource() }); lineInteraction.setActive(false); lineInteraction.on('drawend', onDrawend) { feature.setProperties({ 'id':1234, 'name': 'yourCustomName' }); console.log(feature, feature.getProperties()); }); 

Is it the OpenLayers library reason behind it? The aforementioned example refers to version 3.0.

My full JS fiddle is here: https://jsfiddle.net/fb9mtyz3/

I would like to export the features drawn on my OpenLayers map in GeoJSON format.

So far everything is working apart from the properties section, which keeps coming with nothing, as you see below.

enter image description here

I would like to define something for every individual drawing I make on the map.

I found some nice approaches here:

Openlayers 3 draw set name

but it doesn't work in my code:

 var lineInteraction = new ol.interaction.Draw({ type: 'LineString', source: vectorLayer.getSource() }); lineInteraction.setActive(false); lineInteraction.on('drawend', onDrawend) { feature.setProperties({ 'id':1234, 'name': 'yourCustomName' }); console.log(feature, feature.getProperties()); }); 

Is it the OpenLayers library reason behind it? The aforementioned example refers to version 3.0.

My full JS fiddle is here: https://jsfiddle.net/fb9mtyz3/

Source Link
Geographos
  • 3.1k
  • 5
  • 44
  • 121

OpenLayers problem with adding features to custom drawings

I would like to call the features drawn on my own in the OpenLayers map and export them in the .geoJSON format.

So far everything is working apart from the "Properties" section, which keeps coming with nothing, asenter image description here you see below.

I would like to define something for every individual drawing I make on the map.

I found some nice approaches here:

Openlayers 3 draw set name

but it doesn't work in my code:

 var lineInteraction = new ol.interaction.Draw({ type: 'LineString', source: vectorLayer.getSource() }); lineInteraction.setActive(false); lineInteraction.on('drawend', onDrawend) { feature.setProperties({ 'id':1234, 'name': 'yourCustomName' }); console.log(feature, feature.getProperties()); }); 

Is it the OpenLayers library reason behind it? The aforementioned example refers to version 3.0.

My full JS fiddle is here: https://jsfiddle.net/fb9mtyz3/