Tino, Thanks for that it really helped. This should be an example in OL as it could help people like me.
Anyway, I have one small issue which is most likely associated with my application. I overlay a thematic WMS layer on top of my basemap and I use this control to create a polygon to do a getFeature request against the CubeWerx database. So I take the geometry returned in this control and turn it into my own vector polygon to which I bind a drag control so the user can drag it around and reuse it. I also make sure that the thematic map overlay is set to a ZIndex that makes sure its lower than markers, other layers, popups and this temporary vector layer etc. However, in the process of dragging the polygon out, the display polygon appears below my thematic overlay. Once I release the mouse it pops to the top. So is there a way of manipulating (resetting) a control's stretching graphic? Cheers, Brad.... -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: Monday, July 12, 2010 11:07 PM To: [email protected]; [email protected]; [email protected] Subject: Aw: Re: [OpenLayers-Users] RegularPolygon as a search polygon Hello Brad, I think the problem is your own separate EventHandler and the wrong handler "draw". The DrawFeature-Control has an eventhandler "featureAdded". Take this instead. e.g. OpenLayers.Control.NoticeControl = OpenLayers.Class(OpenLayers.Control.DrawFeature, { initialize: function(layer, handler, options) { OpenLayers.Control.DrawFeature.prototype.initialize.apply(this, [layer, handler, options]); }, setMap: function(map) { this.handler.setMap(map); OpenLayers.Control.prototype.setMap.apply(this, arguments); }, featureAdded: function(feature) { alert(feature.geometry.toString()); this.deleteFeature(feature); }, deleteFeature: function(feature) { feature.state = OpenLayers.State.DELETE; this.layer.events.triggerEvent("afterfeaturemodified", {feature: feature}); this.layer.drawFeature(feature); }, CLASS_NAME: "OpenLayers.Control.NoticeControl" }); how to use: var polyOptions = {sides: 4}; var noticeControl = new OpenLayers.Control.NoticeControl(polygonLayer, OpenLayers.Handler.RegularPolygon, {handlerOptions: polyOptions}); map.addControl(noticeControl); hope that works Tino ----- Original Nachricht ---- Von: Brad Spencer <[email protected]> An: [email protected], [email protected] Datum: 11.07.2010 15:23 Betreff: Re: [OpenLayers-Users] RegularPolygon as a search polygon > 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: [email protected] [mailto:[email protected]] 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 > > [email protected] > > 0404 841 131 > > (02)9481 7024 > > > > "DemographicDrapes > <http://www.numaps.com.au/numaps/index.cfm/resources/resources/apps4nsw-comp > > etition-winner/> wins NSW award" > > > > > > -------------------------------- > > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > -- Hotelbewertung: Bloß nicht die Katze im Sack kaufen bzw. den Floh auf der Matratze buchen - ob geschäftlich oder privat - erst das Hotel im Reise-Channel auf arcor.de checken! http://www.arcor.de/rd/footer.hotel _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
