[OpenLayers-Users] DrawFeature with callback?

Adorian Ardelean mynature at gmail.com
Fri Dec 5 07:36:20 EST 2008


Hi,

I presume you have to specify the event name somehow. Try including this:

dosomething = function (feature)
{

}

 ...callbacks: {'featureAdded': dosomething}...


All the best,
Adorian

On Fri, Dec 5, 2008 at 12:59 PM, Nino Saturnino Martinez Vazquez Wael <
nino.martinez at jayway.dk> wrote:

> Hi Guys
>
> Im doing a integration for the Apache Wicket framework(
>
> http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-openlayers
> ), and want to add some more features. Im looking into adding the
> possibility to draw polygons, however I cant find a example where theres
> a simple callback involved once the polygon are drawn, however the api
> mentions it's possible.
>
> As you can see from the below code the only thing I need for this little
> thing to work are the function that calls the alert to be picked up.
> Please say if you want me to elaborate further.
>
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>  <head>
>    <title>OpenLayers Regular Polygon Example</title>
>    <script src="http://openlayers.org/api/OpenLayers.js"></script>
>    <script type="text/javascript">
>        var map, polygonControl;
>        OpenLayers.Util.onImageLoadErrorColor = "transparent";
>        function init(){
>            map = new OpenLayers.Map('map');
>
>            var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
>                "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
>
>            var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
>
>            map.addLayers([wmsLayer, polygonLayer]);
>            map.addControl(new OpenLayers.Control.LayerSwitcher());
>            map.addControl(new OpenLayers.Control.MousePosition());
>
>            polyOptions = {sides: 4, callbacks:
> {function(value){alert('yeeeha');}}  };
>            polygonControl = new
> OpenLayers.Control.DrawFeature(polygonLayer,
>
> OpenLayers.Handler.RegularPolygon,
>                                            {handlerOptions: polyOptions
>                                                });
>
>            map.addControl(polygonControl);
>
>            map.setCenter(new OpenLayers.LonLat(0, 0), 3);
>
>            document.getElementById('noneToggle').checked = true;
>             document.getElementById('irregularToggle').checked = false;
>        }
>        function setOptions(options) {
>            polygonControl.handler.setOptions(options);
>        }
>        function setSize(fraction) {
>            var radius = fraction * map.getExtent().getHeight();
>            polygonControl.handler.setOptions({radius: radius,
>                                               angle: 0});
>        }
>    </script>
>
>  </head>
>  <body onload="init()">
>    <h2 id="title">OpenLayers Regular Polygon Example</h2>
>    <p id="shortdesc">
>      Shows how to use the RegularPolygon handler to draw features with
>      different numbers of sides.
>    </p>
>    <div id="map" class="smallmap"></div>
>    <div id="config">
>
>        <ul id="controls"><b>Map Controls</b>
>
>            <li>
>                <input type="radio" name="type"
>                       value="none" id="noneToggle"
>                       onclick="polygonControl.deactivate()"
>                       checked="checked" />
>                <label for="noneToggle">navigate</label>
>            </li>
>            <li>
>                <input type="radio" name="type"
>                       value="polygon" id="polygonToggle"
>                       onclick="polygonControl.activate()" />
>                <label for="polygonToggle">draw polygon</label>
>            </li>
>
>        </ul>
>
>    </div>
>  </body>
>
> </html>
>
>
>
>
> -Nino
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Dr. Adorian Ardelean
coordinator of myNature Project

http://mybiosis.info/nature/portal.php?pagename=firstpage [a Romanian
biodiversity-database]
http://mybiosis.info/nature/portal.php?pagename=adorian [CV]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081205/388a4cd4/attachment.html


More information about the Users mailing list