Sketch event in Openlayers 3 drawing interaction

المشرف العام

Administrator
طاقم الإدارة
For drawing Polygon in OpenLayers 2 we could use as follow:

function drawEnd(){ ... } function putPoint(){ ... } function sketchModified(){ ... } function cancel(){ ... } var callBackParams = { "done": drawEnd, "point": putPoint, "modify": sketchModified, "cancel": cancel } var drawCrtl = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {callBacks: callBackParams}); map.addControls([drawCrtl]); drawCrtl.activate(); When we put point to drawing the polygon, the system call putPoint function. When mouse move over the map, it call sketchModified function. I want to use these two Event in OpenLayers 3. I define my layer as follow:

var source = new ol.source.Vector({wrapX: false}); var vector = new ol.layer.Vector({ source: source }); draw = new ol.interaction.Draw({ source: source, type: 'Polygon' }); drawStart = function(){ console.log("Salam Bar Mahdi"); } drawEnd = function(){ console.log("Ya Mahdi"); } draw.on('drawstart', drawStart); draw.on('drawend', drawEnd); var map = new ol.Map({ interactions: ol.interaction.defaults().extend([select, modify, draw]), target: 'map', layers: [ new ol.layer.Tile({ title: "Global Imagery", source: new ol.source.TileWMS({ url: 'http://localhost:8080/geoserver/world/wms?service=WMS', params: {LAYERS: 'world:worldRaster', VERSION: '1.1.1'} }) }), vector ], view: new ol.View({ projection: 'EPSG:4326', center: [0, 0], zoom: 4 }) }); But in Openlayers 3 I saw only drawEnd and DrawStart Event.

How Can I do?



أكثر...
 
أعلى