I have generated attributes for a drawn polygon on a vector layer. While selecting the drawn polygon on map i am getting geneated features on a table. But i want to store in same Json file where i am getting Json vector layer.
How to do it? Please help me..
` var wkt = new ol.format.GeoJSON(); // Create a draw interaction and add it to the map: var drawInteraction = new ol.interaction.Draw({ source : floodAlertLayer.getSource(), type : 'Polygon' }); map.addInteraction(drawInteraction); // Update geometry and change mode to modify after drawing is finished: drawInteraction.on('drawend', function(e) { var feature = e.feature; feature.set("REGION", "AnglianRegion"); feature.set("AREA", "Central"); feature.set("FWD_TACODE", "052FAGBURY"); feature.set("FWIS_CODE", "052FAGBURY"); feature.set("FWA_NAME", "GroundwaterFloodinginBuryStEdmunds"); feature.set("RIVER_SEA", ""); feature.set("COUNTY", "Suffolk"); feature.set("DESCRIP", "Areas") zoom = map.getView().getZoom(); center = map.getView().getCenter(); console.log(center); // remove draw interaction: map.removeInteraction(drawInteraction); map.setView(new ol.View({ center : center, zoom : zoom })); // Create a select interaction and add it to the map: var selectInteraction = new ol.interaction.Select(); map.addInteraction(selectInteraction); // select feature: selectInteraction.getFeatures().push(feature); // clone feature: var featureClone = feature.clone(); // transform cloned feature to WGS84: featureClone.getGeometry().transform('EPSG:3857', 'EPSG:4326'); // update geometry: //document.getElementById("wkt").value = wkt.writeFeature(featureClone); // Create a modify interaction and add to the map: var modifyInteraction = new ol.interaction.Modify({ features : selectInteraction.getFeatures() }); map.addInteraction(modifyInteraction); // set listener to update geometry when feature is changed: feature.on('change', function() { // clone feature: var featureClone = feature.clone(); // transform cloned feature to WGS84: featureClone.getGeometry().transform('EPSG:3857', 'EPSG:4326'); // set modified WKT: modifiedWKT = wkt.writeFeature(featureClone); //alert(floodAlertLayer.getSource().getFeatures('COUNTY')); }); });`
أكثر...
How to do it? Please help me..
` var wkt = new ol.format.GeoJSON(); // Create a draw interaction and add it to the map: var drawInteraction = new ol.interaction.Draw({ source : floodAlertLayer.getSource(), type : 'Polygon' }); map.addInteraction(drawInteraction); // Update geometry and change mode to modify after drawing is finished: drawInteraction.on('drawend', function(e) { var feature = e.feature; feature.set("REGION", "AnglianRegion"); feature.set("AREA", "Central"); feature.set("FWD_TACODE", "052FAGBURY"); feature.set("FWIS_CODE", "052FAGBURY"); feature.set("FWA_NAME", "GroundwaterFloodinginBuryStEdmunds"); feature.set("RIVER_SEA", ""); feature.set("COUNTY", "Suffolk"); feature.set("DESCRIP", "Areas") zoom = map.getView().getZoom(); center = map.getView().getCenter(); console.log(center); // remove draw interaction: map.removeInteraction(drawInteraction); map.setView(new ol.View({ center : center, zoom : zoom })); // Create a select interaction and add it to the map: var selectInteraction = new ol.interaction.Select(); map.addInteraction(selectInteraction); // select feature: selectInteraction.getFeatures().push(feature); // clone feature: var featureClone = feature.clone(); // transform cloned feature to WGS84: featureClone.getGeometry().transform('EPSG:3857', 'EPSG:4326'); // update geometry: //document.getElementById("wkt").value = wkt.writeFeature(featureClone); // Create a modify interaction and add to the map: var modifyInteraction = new ol.interaction.Modify({ features : selectInteraction.getFeatures() }); map.addInteraction(modifyInteraction); // set listener to update geometry when feature is changed: feature.on('change', function() { // clone feature: var featureClone = feature.clone(); // transform cloned feature to WGS84: featureClone.getGeometry().transform('EPSG:3857', 'EPSG:4326'); // set modified WKT: modifiedWKT = wkt.writeFeature(featureClone); //alert(floodAlertLayer.getSource().getFeatures('COUNTY')); }); });`
أكثر...