I added two vector layers which are downloaded from geoserver into my eclipse and i am displaying the layers on osm layer. After i added drawing features on vectorlayers i cannot able to save features in json files. and i cannot able to display features on div tag on drawing interactions. please help me.
function addInteraction() { draw = new ol.interaction.Draw({ source: floodAlertLayer.getSource(), type: typeSelect.value }); map.addInteraction(draw); draw.on('drawend', function(evt) { console.log(evt.feature); var parser = new ol.format.GeoJSON(); var features = floodAlertLayer.getSource().getFeatures(); var featuresGeoJSON = parser.writeFeatures(features); var text = JSON.stringify(featuresGeoJSON); // document.getElementById('info').innerHTML = text; // alert(features.get("COUNTY")); $.ajax({ url: 'FloodAlert.json', type: 'POST', data: text }).then(function(response) { console.log(response); }); }, this); }
أكثر...
function addInteraction() { draw = new ol.interaction.Draw({ source: floodAlertLayer.getSource(), type: typeSelect.value }); map.addInteraction(draw); draw.on('drawend', function(evt) { console.log(evt.feature); var parser = new ol.format.GeoJSON(); var features = floodAlertLayer.getSource().getFeatures(); var featuresGeoJSON = parser.writeFeatures(features); var text = JSON.stringify(featuresGeoJSON); // document.getElementById('info').innerHTML = text; // alert(features.get("COUNTY")); $.ajax({ url: 'FloodAlert.json', type: 'POST', data: text }).then(function(response) { console.log(response); }); }, this); }
أكثر...