how can i get the coordinates value on drawing of polygon at each mouse
click , actually i want to store each coordinates i clicked  during vector
drawing.

 currently i use this for vector drawing controls but at time of drawing i
cannot get the coordinates at each point i clicked during drawing.

    controls = {
        point: new OpenLayers.Control.DrawFeature(vectors,
                                OpenLayers.Handler.Point),
        line: new OpenLayers.Control.DrawFeature(vectors,
                                OpenLayers.Handler.Path),
        polygon: new OpenLayers.Control.DrawFeature(vectors,
                                OpenLayers.Handler.Polygon),
        drag: new OpenLayers.Control.DragFeature(vectors),
       select: select,
        regular: new OpenLayers.Control.DrawFeature(vectors,
                            OpenLayers.Handler.RegularPolygon,
                            { handlerOptions: { sides: 5} }),
        modify: new OpenLayers.Control.ModifyFeature(vectors)
           };

    for (var key in controls) {
        map.addControl(controls[key]);
    }

and for reading mouse i use :
    map.addControl(new
OpenLayers.Control.MousePosition({element:document.getElementById("longlats"),
numdigits:3}));

if it is in navigation only mode i can read and store mouse click as :
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: {
        'single': true,
        'pixelTolerance': 0 //,       // 'stopSingle': false
    },
    initialize: function(options) {
        this.handlerOptions = OpenLayers.Util.extend(
                        {}, this.defaultHandlerOptions
                    );
        OpenLayers.Control.prototype.initialize.apply(
                        this, arguments
                    );
        this.handler = new OpenLayers.Handler.Click(
                        this, { 'click': this.trigger }, this.handlerOptions
                    );
    },
    trigger: function(e) {
        var lonlat = map.getLonLatFromViewPortPx(e.xy);
        var pos = "Longitude: " + lonlat.lon + " E, <br/>Latitude: " +
lonlat.lat + "N";        // alert("You clicked near " + lonlat.lat + " N, "
+lonlat.lon + " E");//OpenLayers.Util.getElement("longval").innerHTML = pos;
        document.data1.longval.value = lonlat.lon;
        document.data1.latval.value = lonlat.lat;

but i don't got idea how can i combine these all to function together while
drawing vector point, line and polygon


/nabin,
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to