How to start the click event when drawing event is completed in openlayers3

المشرف العام

Administrator
طاقم الإدارة
I added two features for a map. first handles drawing on map and second one which will show the features in a table. when i am drawing the map the second click event is working. so i stopped the event of getfeatures using unByKey(key) in drawing. But how to start the event back after drawing . Please help me`

function draw() { map.unByKey(k1); var wkt = new ol.format.GeoJSON(); var drawInteraction = new ol.interaction.Draw({ source : floodAlertLayer.getSource(), type : 'Polygon' }); map.addInteraction(drawInteraction); drawInteraction.on('drawend', function(e) { alert("feature"); 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); map.removeInteraction(drawInteraction); map.setView(new ol.View({ center : center, zoom : zoom })); var selectInteraction = new ol.interaction.Select(); map.addInteraction(selectInteraction); selectInteraction.getFeatures().push(feature); var featureClone = feature.clone(); featureClone.getGeometry().transform('EPSG:3857', 'EPSG:4326'); var modifyInteraction = new ol.interaction.Modify({ features : selectInteraction.getFeatures() }); map.addInteraction(modifyInteraction); feature.on('change', function() { var featureClone = feature.clone(); featureClone.getGeometry().transform('EPSG:3857', 'EPSG:4326'); modifiedWKT = wkt.writeFeature(featureClone); }); map.removeInteraction(modifyInteraction); }); } var myTable = ""; var displayFeatureInfo = function(pixel) { var features = []; map.forEachFeatureAtPixel(pixel, function(feature, layer) { features.push(feature); }); if (features.length > 0) { var info = []; var i, ii; for (i = 0, ii = features.length; i < ii; ++i) { myTable += '' + features.get('REGION') + ''; myTable += '' + features.get('AREA') + ''; myTable += '' + features.get('FWD_TACODE') + ''; myTable += '' + features.get('FWIS_CODE') + ''; myTable += '' + features.get('FWA_NAME') + ''; myTable += '' + features.get('DESCRIP') + ''; myTable += '' + features.get('COUNTY') + ''; myTable += '' + features.get('RIVER_SEA') + ''; } document.getElementById('info').innerHTML = myTable; } else { document.getElementById('info').innerHTML = ' '; } } var key=function(evt){ myTable = ""; myTable += 'Feature IDREGIONAREAFWD_TACODEFWIS_CODEFWA_NAMEDESCRIPCOUNTYRIVER_SEA'; mywarningTable = ""; mywarningTable += 'Feature IDREGION'; displayFeatureInfo(evt.pixel); } var k1=map.on('click',key); function enable() { map.un('click',key); }`

أكثر...
 
أعلى