Hi Nino,<br><br>This works ok for me:<br><br><span style="color: rgb(0, 0, 153);">dosomething = function (feature)</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">{</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);"> //do something with polygon</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);"> alert("yeeehaaa");</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);">};</span><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">controls = {</span><br style="color: rgb(0, 0, 153);">
<span style="color: rgb(0, 0, 153);"> polygon: new OpenLayers.Control.DrawFeature(regions,OpenLayers.Handler.Polygon, {'featureAdded': dosomething})</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">}</span><br>
<br><br>All the best,<br>Adorian<br><br><br><div class="gmail_quote">On Fri, Dec 5, 2008 at 2:03 PM, Nino Saturnino Martinez Vazquez Wael <span dir="ltr"><<a href="mailto:nino.martinez@jayway.dk">nino.martinez@jayway.dk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Okay so I now have this, still not working though:<div class="Ih2E3d"><br>
<br>
<br>
<html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>"><br>
<head><br>
<title>OpenLayers Regular Polygon Example</title><br>
<script src="<a href="http://openlayers.org/api/OpenLayers.js" target="_blank">http://openlayers.org/api/OpenLayers.js</a>"></script><br>
<script type="text/javascript"><br>
var map, polygonControl;<br>
OpenLayers.Util.onImageLoadErrorColor = "transparent";<br>
function init(){<br>
map = new OpenLayers.Map('map');<br>
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",<br>
"<a href="http://labs.metacarta.com/wms/vmap0" target="_blank">http://labs.metacarta.com/wms/vmap0</a>?", {layers: 'basic'});<br>
<br>
var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");<br>
<br>
map.addLayers([wmsLayer, polygonLayer]);<br>
map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
map.addControl(new OpenLayers.Control.MousePosition());<br>
<br></div>
dosomething = function (polygon)<br>
{<br>
//do something with polygon<br>
alert("yeeehaaa");<br>
};<br>
<br>
polyOptions = {sides: 4, callbacks: {'featureAdded': dosomething} };<div class="Ih2E3d"><br>
polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,<br>
OpenLayers.Handler.RegularPolygon,<br>
{handlerOptions: polyOptions<br>
});<br>
map.addControl(polygonControl);<br>
map.setCenter(new OpenLayers.LonLat(0, 0), 3);<br>
document.getElementById('noneToggle').checked = true;<br>
}<br></div><div><div></div><div class="Wj3C7c">
function setOptions(options) {<br>
polygonControl.handler.setOptions(options);<br>
}<br>
function setSize(fraction) {<br>
var radius = fraction * map.getExtent().getHeight();<br>
polygonControl.handler.setOptions({radius: radius,<br>
angle: 0});<br>
}<br>
</script><br>
<br>
</head><br>
<body onload="init()"><br>
<h2 id="title">OpenLayers Regular Polygon Example</h2><br>
<p id="shortdesc"><br>
Shows how to use the RegularPolygon handler to draw features with<br>
different numbers of sides.<br>
</p><br>
<div id="map" class="smallmap"></div><br>
<div id="config"><br>
<ul id="controls"><b>Map Controls</b><br>
<br>
<li><br>
<input type="radio" name="type"<br>
value="none" id="noneToggle"<br>
onclick="polygonControl.deactivate()"<br>
checked="checked" /><br>
<label for="noneToggle">navigate</label><br>
</li><br>
<li><br>
<input type="radio" name="type"<br>
value="polygon" id="polygonToggle"<br>
onclick="polygonControl.activate()" /><br>
<label for="polygonToggle">draw polygon</label><br>
</li><br>
<br>
</ul><br>
<br>
</div><br>
</body><br>
<br>
</html><br>
<br>
<br></div></div>
Adorian Ardelean wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
Hi,<br>
<br>
I presume you have to specify the event name somehow. Try including this:<br>
<br>
dosomething = function (feature)<br>
{<br>
<br>
}<br>
<br>
...callbacks: {'featureAdded': dosomething}...<br>
<br>
<br>
All the best,<br>
Adorian<br>
<br></div><div><div></div><div class="Wj3C7c">
On Fri, Dec 5, 2008 at 12:59 PM, Nino Saturnino Martinez Vazquez Wael <<a href="mailto:nino.martinez@jayway.dk" target="_blank">nino.martinez@jayway.dk</a> <mailto:<a href="mailto:nino.martinez@jayway.dk" target="_blank">nino.martinez@jayway.dk</a>>> wrote:<br>
<br>
Hi Guys<br>
<br>
Im doing a integration for the Apache Wicket framework(<br>
<a href="http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-openlayers" target="_blank">http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-openlayers</a><br>
), and want to add some more features. Im looking into adding the<br>
possibility to draw polygons, however I cant find a example where<br>
theres<br>
a simple callback involved once the polygon are drawn, however the api<br>
mentions it's possible.<br>
<br>
As you can see from the below code the only thing I need for this<br>
little<br>
thing to work are the function that calls the alert to be picked up.<br>
Please say if you want me to elaborate further.<br>
<br>
<br>
<html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>"><br>
<head><br>
<title>OpenLayers Regular Polygon Example</title><br>
<script src="<a href="http://openlayers.org/api/OpenLayers.js" target="_blank">http://openlayers.org/api/OpenLayers.js</a>"></script><br>
<script type="text/javascript"><br>
var map, polygonControl;<br>
OpenLayers.Util.onImageLoadErrorColor = "transparent";<br>
function init(){<br>
map = new OpenLayers.Map('map');<br>
<br>
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",<br>
"<a href="http://labs.metacarta.com/wms/vmap0" target="_blank">http://labs.metacarta.com/wms/vmap0</a>?", {layers:<br>
'basic'});<br>
<br>
var polygonLayer = new OpenLayers.Layer.Vector("Polygon<br>
Layer");<br>
<br>
map.addLayers([wmsLayer, polygonLayer]);<br>
map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
map.addControl(new OpenLayers.Control.MousePosition());<br>
<br>
polyOptions = {sides: 4, callbacks:<br>
{function(value){alert('yeeeha');}} };<br>
polygonControl = new<br>
OpenLayers.Control.DrawFeature(polygonLayer,<br>
<br>
OpenLayers.Handler.RegularPolygon,<br>
{handlerOptions:<br>
polyOptions<br>
});<br>
<br>
map.addControl(polygonControl);<br>
<br>
map.setCenter(new OpenLayers.LonLat(0, 0), 3);<br>
<br>
document.getElementById('noneToggle').checked = true;<br>
document.getElementById('irregularToggle').checked =<br>
false;<br>
}<br>
function setOptions(options) {<br>
polygonControl.handler.setOptions(options);<br>
}<br>
function setSize(fraction) {<br>
var radius = fraction * map.getExtent().getHeight();<br>
polygonControl.handler.setOptions({radius: radius,<br>
angle: 0});<br>
}<br>
</script><br>
<br>
</head><br>
<body onload="init()"><br>
<h2 id="title">OpenLayers Regular Polygon Example</h2><br>
<p id="shortdesc"><br>
Shows how to use the RegularPolygon handler to draw features with<br>
different numbers of sides.<br>
</p><br>
<div id="map" class="smallmap"></div><br>
<div id="config"><br>
<br>
<ul id="controls"><b>Map Controls</b><br>
<br>
<li><br>
<input type="radio" name="type"<br>
value="none" id="noneToggle"<br>
onclick="polygonControl.deactivate()"<br>
checked="checked" /><br>
<label for="noneToggle">navigate</label><br>
</li><br>
<li><br>
<input type="radio" name="type"<br>
value="polygon" id="polygonToggle"<br>
onclick="polygonControl.activate()" /><br>
<label for="polygonToggle">draw polygon</label><br>
</li><br>
<br>
</ul><br>
<br>
</div><br>
</body><br>
<br>
</html><br>
<br>
<br>
<br>
<br>
-Nino<br>
_______________________________________________<br>
Users mailing list<br></div></div>
<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a> <mailto:<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a>><div class="Ih2E3d"><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<br>
<br>
<br>
<br>
-- <br>
Dr. Adorian Ardelean<br>
coordinator of myNature Project<br>
<br>
<a href="http://mybiosis.info/nature/portal.php?pagename=firstpage" target="_blank">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian biodiversity-database]<br>
<a href="http://mybiosis.info/nature/portal.php?pagename=adorian" target="_blank">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br>
</div></blockquote><font color="#888888">
<br>
-- <br>
-Wicket for love<br>
<br>
Nino Martinez Wael<br>
Java Specialist @ Jayway DK<br>
<a href="http://www.jayway.dk" target="_blank">http://www.jayway.dk</a><br>
+45 2936 7684<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Dr. Adorian Ardelean<br>coordinator of myNature Project<br><br><a href="http://mybiosis.info/nature/portal.php?pagename=firstpage">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian biodiversity-database]<br>
<a href="http://mybiosis.info/nature/portal.php?pagename=adorian">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br><br>