Ok I've managed to do the first thing by looking on the examples.
I think there must be a better ways to do this just like you draw the
"point" on the layer

so this is what i've done:

   
OpenLayers.Event.observe($('map'),"click",mapclicked.bindAsEventListener(map));

   function mapclicked(e){
                var lonlat = map.getLonLatFromPixel(e.xy);
                var shape = "POLYGON(("+(lonlat.lon-5)+" "+(lonlat.lat-5)+",
"+(lonlat.lon-5)+" "+(lonlat.lat+5)+", "+(lonlat.lon+5)+"
"+(lonlat.lat+5)+", "+(lonlat.lon+5)+" "+(lonlat.lat-5)+"))";
                //shape = "POINT("+lonlat.lon+" " +lonlat.lat+")";

                //load shape
                loadVector(shape);
            };

        function loadVector(coords) {
            var features = formats['in']['wkt'].read(coords);
            var bounds;
            if(features) {
                if(features.constructor != Array) {
                    features = [features];
                }
                for(var i=0; i<features.length; ++i) {
                    if (!bounds) {
                        bounds = features[i].geometry.getBounds();
                    } else {
                        bounds.extend(features[i].geometry.getBounds());
                    }
                }
                vectors.addFeatures(features);
                var plural = (features.length > 1) ? 's' : '';
                //alert( features.length + ' feature' + plural + ' added' );
            } else {
                alert( 'Bad input ' + type );
            }
        }

the curser place is from the "Cursor Example"
and the load vector method is original from the "deserialize" of the "Vector
Formats Example"

if i want it to work like the radio buttons examples I should add an if
statment in the function mapclicked to check if it's checked.

 its working but not like the way the "OpenLayers" implment it.
how can i integred it with the toggleControl function?
and still i have the second, drag, issue


2010/11/26 jumpNg mo0 <[email protected]>

>  Hello list
> I'm using this example to draw new vectors
> http://openlayers.org/dev/examples/drag-feature.html
>
> I have some issues
>
> 1. How do I create another option to contain a Polygon with a specific size
> I'm choosing
> for example, when I check the "box" radio option, a new radio button for
> this case, it will draw a whole shape, a squre 10x10, where ever I click on
> the map.
> so if I'll clicl on the (0, 0) point is will be that POLYGON((0 0, 0 10, 10
> 10, 10 0)) and on every other point the fixed coordinates for the 10x10
> square POLYGON.
>
> 2. I want to make sure that, when I draw new vectors OR when I drag
> existence vectors, the vectors could not get run over by another vector.
> instead, I want it to not to create the new vector and maybe run an error
> (alert) OR to stop the draging at the touching point (the way the mouse
> pointer came from).
>
> -----------------
> jumpNg
>
> --
> -----------------
> jumpNg
>


-- 
-----------------
jumpNg
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to