How to perform modify feature on polygon in Open Layers 2 without click

المشرف العام

Administrator
طاقم الإدارة
//Create the control collection to draw vectorial features. var controls = { polygon: new OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Polygon), modify: new OpenLayers.Control.ModifyFeature(vectorLayer, { deferDelete: false, eventListeners: { 'beforefeaturedeleted': reportEvent, 'featuredeleted': reportEvent }, tools: [ // custom tools { // to rotate the "angle" attribute of a ponit by steps of 15 degrees geometryTypes: ['OpenLayers.Geometry.Point', 'OpenLayers.Geometry.MultiPoint'], dragAction: function(feature, initialAtt, escale, rotation) { var angle = ((initialAtt.angle || 0) - rotation) % 360; // force steps of 15 degrres angle = Math.floor(angle / 15) * 15; feature.attributes.angle = angle; }, style: OpenLayers.Control.ModifyFeature_styles.rotate }, { // to resize the pointRadius. geometryTypes: ['OpenLayers.Geometry.Point', 'OpenLayers.Geometry.MultiPoint'], dragAction: function(feature, initialAtt, escale, rotation) { var radius = (initialAtt.radius || 6) * escale; feature.attributes.radius = Math.max(6, radius); }, style: OpenLayers.Control.ModifyFeature_styles.resize }, { // to close a lineString as a ring geometryTypes: ['OpenLayers.Geometry.LineString'], pressingAction: function(feature) { var geometry = feature.geometry; geometry.addComponent(geometry.components[0].clone()); }, style: { label:'ring', title: 'press to close as a ring', cursor: "pointer", fontSize: '8px', fontColor: '#222', pointRadius: 10, fillColor: '#cccccc', strokeColor: '#444444' } }] }) }; function modify(polygonID) { polygonID=4; //supoose id=4 var features=vectorLayer.getFeaturesByAttribute('id',polygonID); var control = controls['modify']; control.activate(); console.log(features); // Need to write a code required to modify feature on selected co-ordinates with the features obtained from above.Currently need to perform a click on the polygon but need to avoid that and perform that programetically. } I just need the click operation automated with modify control. I am a beginner with OSM.Any help would be appreciated.



أكثر...
 
أعلى