[OpenLayers-Users] drawFeature control needs two clicks...?

Chris Green chris.green at ibstv.co.uk
Thu Apr 15 11:37:35 EDT 2010


Dear all

 

I have a situation that I can't get to the bottom of, and I'm hoping that
someone can help me understand it. The following code is intended to add a
new circle each time the user clicks a map, which it does.

 

My problem is that two clicks are needed for any circle to be drawn: it is
as if the first click activates the drawFeature control (and also removes
any existing circle) but does not draw anything, and then a second click
draws the feature.  So far as I can understand two clicks should not be
needed..? Any suggestions what I am doing wrong please?

 

 

 

Chris

 

 

 

 

       circle1Layer = new OpenLayers.Layer.Vector("Circle 1", {

                 styleMap : circle1Style

             }); 

         

            map.addLayer(circle1Layer);

            map.addControl(new OpenLayers.Control.MousePosition());

   

           function circle1FeatureAdded(feature){

           if (circle1.activate=true){

           circle1.deactivate();

             }

           }

   

           var circle1Options = {sides:20, radius: Radius, persist: true};

           circle1 = new OpenLayers.Control.DrawFeature(circle1Layer,

            OpenLayers.Handler.RegularPolygon,

            {handlerOptions: circle1Options}

             );

          

          map.addControl(circle1);

          

           circle1.activate();

           

           circle1.events.register('featureadded', circle1,

           circle1FeatureAdded);

          

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100415/1a7dac4c/attachment.html


More information about the Users mailing list