i am trying to develop a webmapping application using openlayers, geoserver, JSF javascript. I published my postgis layers on geoserver and added them to a google basemap on a xhtml page using a javascript code. Now i want to edit one of the layers i published. on the script i added the folowing code :

function  drawpoint(){
          //nouveau_risque = new OpenLayers.Layer.Vector("nouveau risque");
           drawControl = new OpenLayers.Control.DrawFeature(nouveau_risque, OpenLayers.Handler.Point);
         // drawControl.events.register('featureadded', drawControl, onFeatureAdded);
          drawControl.events.register('featureadded', drawControl, function(f) {

                // create a WKT reader/parser/writer          
                var wkt = new OpenLayers.Format.WKT();

                 // write out the feature's geometry in WKT format
                 var out = wkt.write(f.feature);
            // drawControl.deactivate();


           function endDraw(){

and on the xhtml page i wrote :

            <input type="button" value="add point" onclick="drawpoint()"> </input>
            <input type="button" value="stop editing" onclick="EndDraw()"> </input>
                   <div  style="width:100px; height:60px"> <script type="test/javascript">document.writeln(out);</script></div>

so that i can get the geom value of the added point so that i can add it to the database.

The problem is when i run the page, the add control is displayed and i can add a pointy however i don't get the feature's geometry in WKT.

Than you all for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.