<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=WordSection1>
<p class=MsoNormal>Guys,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I have been able to build a control to freehand digitize a
polygon and then launch a function to use the polygon as a search polygon in a
WFS request. <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>This works for me:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>drawControls = new
OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Polygon) ;<o:p></o:p></p>
<p class=MsoNormal> //
extend the drawcontrol with its behavior<o:p></o:p></p>
<p class=MsoNormal> OpenLayers.Util.extend(drawControls,
<o:p></o:p></p>
<p class=MsoNormal> { draw:
function (){<o:p></o:p></p>
<p class=MsoNormal style='margin-left:.5in;text-indent:.5in'>this.polygon = new
OpenLayers.Handler.Polygon(drawControls,{"done": this.notice}); this.polygon.activate();},<o:p></o:p></p>
<p class=MsoNormal> notice:
function (polygon)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> //
get vertices of polygon into and array of coordinate pairs<o:p></o:p></p>
<p class=MsoNormal> var
polyString = polygon.toString() ;<o:p></o:p></p>
<p class=MsoNormal> <o:p></o:p></p>
<p class=MsoNormal> //
do whatever with polygon linestring here<o:p></o:p></p>
<p class=MsoNormal style='margin-left:1.0in;text-indent:.5in'>… <o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> });
<o:p></o:p></p>
<p class=MsoNormal> map.addControl(drawControls);<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I wanted to use the RegularPolygon feature to do the same
but it does not launch the function in the same way after the vector geometry
is successfully created. <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>var polyType = 6;<o:p></o:p></p>
<p class=MsoNormal>var rad = ‘’;<o:p></o:p></p>
<p class=MsoNormal>polyOptions = {sides: polyType, radius: rad, angle: 0}<o:p></o:p></p>
<p class=MsoNormal>shapeControl = new
OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.RegularPolygon,
{handlerOptions: polyOptions});<o:p></o:p></p>
<p class=MsoNormal> //
extend the shapeControl with its behavior<o:p></o:p></p>
<p class=MsoNormal> OpenLayers.Util.extend(shapeControl,
<o:p></o:p></p>
<p class=MsoNormal> { draw:
function (){<o:p></o:p></p>
<p class=MsoNormal> this.polygon
= new OpenLayers.Handler.RegularPolygon(shapeControl, {"done":
this.notice}); this.polygon.activate();},<o:p></o:p></p>
<p class=MsoNormal> notice:
function (polygon)<o:p></o:p></p>
<p class=MsoNormal> {<o:p></o:p></p>
<p class=MsoNormal> //
get vertices of polygon into and array of coordinate pairs<o:p></o:p></p>
<p class=MsoNormal> var
polyString = polygon.toString() ;<o:p></o:p></p>
<p class=MsoNormal> //
do whatever with polygon linestring here<o:p></o:p></p>
<p class=MsoNormal> … <o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> });<o:p></o:p></p>
<p class=MsoNormal> <o:p></o:p></p>
<p class=MsoNormal>In both cases the polygon is created and drawn to the
vectorLayer.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Can anyone see anything obviously wrong with the second
piece of code?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Cheers,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><b><span style='font-size:14.0pt'>Brad Spencer<o:p></o:p></span></b></p>
<p class=MsoNormal>General Manager <o:p></o:p></p>
<p class=MsoNormal>NuMaps<o:p></o:p></p>
<p class=MsoNormal><i>"DemographicDrapes"<o:p></o:p></i></p>
<p class=MsoNormal>www.numaps.com.au<o:p></o:p></p>
<p class=MsoNormal>brad@numaps.com.au<o:p></o:p></p>
<p class=MsoNormal>0404 841 131<o:p></o:p></p>
<p class=MsoNormal>(02)9481 7024<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>"<a
href="http://www.numaps.com.au/numaps/index.cfm/resources/resources/apps4nsw-competition-winner/">DemographicDrapes
wins NSW award</a>"<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>