[OpenLayers-Users] RegularPolygon as a search polygon
Brad Spencer
bradspencer at ozemail.com.au
Fri Jul 9 07:12:18 EDT 2010
Guys,
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.
This works for me:
drawControls = new OpenLayers.Control.DrawFeature(vectorLayer,
OpenLayers.Handler.Polygon) ;
// extend the drawcontrol with its behavior
OpenLayers.Util.extend(drawControls,
{ draw: function (){
this.polygon = new OpenLayers.Handler.Polygon(drawControls,{"done":
this.notice}); this.polygon.activate();},
notice: function (polygon)
{
// get vertices of polygon
into and array of coordinate pairs
var polyString =
polygon.toString() ;
// do whatever with polygon
linestring here
.
}
});
map.addControl(drawControls);
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.
var polyType = 6;
var rad = '';
polyOptions = {sides: polyType, radius: rad, angle: 0}
shapeControl = new OpenLayers.Control.DrawFeature(vectorLayer,
OpenLayers.Handler.RegularPolygon, {handlerOptions: polyOptions});
// extend the shapeControl with its behavior
OpenLayers.Util.extend(shapeControl,
{ draw: function (){
this.polygon = new
OpenLayers.Handler.RegularPolygon(shapeControl, {"done": this.notice});
this.polygon.activate();},
notice: function (polygon)
{
// get vertices of polygon
into and array of coordinate pairs
var polyString =
polygon.toString() ;
// do whatever with polygon
linestring here
.
}
});
In both cases the polygon is created and drawn to the vectorLayer.
Can anyone see anything obviously wrong with the second piece of code?
Cheers,
Brad Spencer
General Manager
NuMaps
"DemographicDrapes"
www.numaps.com.au
brad at numaps.com.au
0404 841 131
(02)9481 7024
"DemographicDrapes
<http://www.numaps.com.au/numaps/index.cfm/resources/resources/apps4nsw-comp
etition-winner/> wins NSW award"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100709/19f12ae0/attachment.html
More information about the Users
mailing list