Hi my friend,

yes you are right. But sketchcomplete only fire if i do an double click. But i 
dont want to do an double click. A simple click should deactivated my 
drawControls and finalized the line with 2 vertexs. The problem is that the 
finalized method only works if i do an double click.

Whats my mistake? Have you an idea?
Thanks in advise,
x_tls_x  

2010/10/14 Moataz Elmasry <[email protected]>:
> Hi
>
> sketchmodified is fired whenever mouse is moved while in "drawing mode". I
> think you need to listen to sketch complete, which is fired when a new
> vertex is added.
> Your code idea is kinda right, but maybe you only do
>
> mLayer.events.on({
>             sketchcomplete : function(event) {
>                 var feature = event.feature;
>                 if(feature.geometry.components.length == 2) {
>                     drawControls.deactivate();
>                    drawControls.line.handler.finalize();                }
>             }
>        });
> regards
>
>
>
> x_tls_x wrote:
>>
>> Hi friends,
>>
>> i want to catch up the layer event with sketchmodified: function. It works
>> 'half' - i can only draw 2 vertexs, but cannot finalized that.
>>
>> Here is the code:
>> // draw controls
>>        var options = {handlerOptions: {}};
>>        drawControls = {
>>                
>>            m: new OpenLayers.Control.DrawFeature(mLayer,
>>                 OpenLayers.Handler.Path, options)
>>        };
>>
>>        for(var key in drawControls) {
>>                map.addControl(drawControls[key]);
>>                }
>>        
>>        mLayer.events.on({
>>             sketchmodified: function(event) {
>>                 var feature = event.feature;
>>                 if(feature.geometry.components.length > 2) {
>>                     feature = feature.clone();
>>                     var geome = feature.geometry;
>>                     geome.removeComponent(geome.component[2]);
>>                     drawControls.deactivate();
>>                     layer.addFeatures([feature]);                    
>>  drawControls.line.handler.finalize();            }
>>             }
>>        });
>> Whats my mistake? Have anyone an idea?
>>
>> Thanks in advise,
>> x_tls_x  
>
>


-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to