[OpenLayers-Users] RegularPolygon as a search polygon
Brad Spencer
bradspencer at ozemail.com.au
Sun Jul 11 09:23:00 EDT 2010
Guys,
Still need some help on this.
I have taken the simple app from examples and edited it to see if I can make
this work. It works but not the way I expect it to work?
See : http://staging.demos.numaps.com.au/shape_tester.html
I have extended the DrawFeature control to echo out the coordinates of the
vector generated polygon. When the control is deactivated (controlled by the
'navigate' radio) the notice function is triggered - not sure why?
I am trying to trigger this function only when the control is activated.
Its just not doing what I would have expected so I must be doing something
really stupid.
Can someone have a quick look at this for me?
Cheers.
Brad..
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
Behalf Of Brad Spencer
Sent: Friday, July 09, 2010 9:12 PM
To: openlayers users
Subject: [OpenLayers-Users] RegularPolygon as a search polygon
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/20100711/b09d8060/attachment.html
More information about the Users
mailing list