[OpenLayers-Users] Storing vectors in OL

Andrew Larcombe andrew at andrewlarcombe.co.uk
Fri May 11 06:25:01 EDT 2007


On 11 May 2007, at 10:07, Przemysław Bojczuk wrote:

> Hello, list!
>
> Since there is no (known to me) way to save drawn/edited vectors  
> (as in
> http://openlayers.org/dev/examples/editingtoolbar.html) to any kind of
> file, is it possible to store them in a permalink? As far as I know,
> permalink only stores layers, extent and zoom, but could it be  
> possible
> to extend it to store the drawn vectors as well?
>


You should be able to create a function which posts your drawn object  
to a server where you can, for example, store it in a database for  
future use. eg for a box you could do something like this (warning,  
this code may not work ootb):

/******

var onBoxDrawn = function(box) {
	//post the contents of box to the server	
}


drawControl = new OpenLayers.Control();
OpenLayers.Util.extend(drawControl, {
	                draw: function () {
	                    // this Handler.Box will intercept the shift- 
mousedown
	                    // before Control.MouseDefault gets to see it
	                    this.box = new OpenLayers.Handler.Box( drawControl,
	                        {"done": this.notice},
	                        {keyMask: OpenLayers.Handler.MOD_SHIFT});
	                    this.box.activate();
	                },	

	                notice: onBoxDrawn
  });

********/

add the drawControl to a panel, and add the panel to a map. This will  
allow you to shift-drag a rectangle and when you've finished drawing  
the onBoxDrawn function gets called.

Hope that makes sense.

Cheers,

Andrew


---
Andrew Larcombe
Freelance Geospatial, Database & Web Programming

web: http://www.andrewlarcombe.co.uk
email: andrew at andrewlarcombe.co.uk
icq: 306690163







More information about the Users mailing list