Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

hi i'm using code from osgeo with some modifications but somehow i can't insert data i think is a projection issue but i cant figure it out. Thanks in advance

    Ext.onReady(function() {

var saveStrategy = new OpenLayers.Strategy.Save();
    saveStrategy.events.register("success",'',showSuccessMsg);
     var options = {
        projection: new OpenLayers.Projection("EPSG:900913"),
                   displayProjection: new OpenLayers.Projection("EPSG:4326"),
                   units: "m",
        numZoomLevels: 20,
                   maxResolution: 156543.0339,
                   minZoomLevels:3,
        maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)
           };
           map = new OpenLayers.Map(options);

    //Adding mouse coordinates y otros controles al mapa
           map.addControl(new OpenLayers.Control.MousePosition());


    //Adding Google Street Map
           var gmap = new OpenLayers.Layer.Google(
           "Google Streets", // the default
           {isBaseLayer: true, numZoomLevels: 20, sphericalMercator: true}
            );

           map.addLayer(gmap);

     //Adding Google Sattelite
            var gsat = new OpenLayers.Layer.Google(
           "Google Satellite",
           {type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 20}
           );

           map.addLayer(gsat);
           var layerMapnik = new OpenLayers.Layer.OSM();
           map.addLayer(layerMapnik);



    /*
    var layer = new OpenLayers.Layer.Vector("vector", {
                           strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy],
                           //strategies: [new OpenLayers.Strategy.Fixed()],
                           protocol: new OpenLayers.Protocol.WFS({
                                   url: "http://ip/geoserver/wfs",
                                  version: "1.1.0",
                           //      geometryName: "the_geom",
                                  featureType: "cocbba",
                                  featureNS: "http://www.opengeospatial.net/cite",
                                  srsName: "EPSG:900913"
                           })
                   });*/

             var layer = new OpenLayers.Layer.Vector("vector", {
           //isBaseLayer:true,
           strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
           projection: new OpenLayers.Projection("EPSG:900913"),       
           protocol: new OpenLayers.Protocol.WFS({
               version: "1.0.0",
               url: "http://ip/geoserver/wfs",
                              featureNS: "http://www.opengeospatial.net/cite",
                              maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34),
               featureType: "cbba",
               geometryName: "the_geom",
               schema: "http://ip/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&TypeName=cite: cbba"
           })

       });        


   map.addLayer(layer);   


                      var cols = [ {name: 'Name', type: 'string'},
         //   {name: 'country', type: 'string'},
          //  {name: 'population', type: 'integer'},
            {name: 'Latitud', type: 'float'},
            {name: 'Longitud', type: 'float'}
                           ];

                   // var reader = new GeoExt.data.FeatureReader({},cols);

                           var store = new GeoExt.data.FeatureStore({
                           //reader: reader,
                           fields: cols,
                           layer: layer,
                           addFeatureFilter: function(feature) {
                                  return feature.state !== OpenLayers.State.DELETE;
                           }
                           });



                   var drawControl = new OpenLayers.Control.DrawFeature(
                           layer,
                           OpenLayers.Handler.Point,
                           {handlerOptions: {multi: true}}
                   );


                   var mapPanel = new GeoExt.MapPanel({
                           title: "Map",
                           region: "center",
                           width: 800,
                           layers: [layer],
                           //extent: new OpenLayers.Bounds(234758, 6402776, 1339075, 8020511),
                           map: map,
                           bbar: [
                                  new GeoExt.Action({
                                          control: drawControl,
                                          text: "Insertar",
                                          enableToggle: true
                                  }), {
                                          text: "Borrar",
                                          handler: function() {
                                                  gridPanel.getSelectionModel().each(function(rec) {
                                                         var feature = rec.get("feature");
                                                         modifyControl.unselectFeature(feature);
                                                         store.remove(rec);
                                                         if(feature.state !== OpenLayers.State.INSERT) {
                                                                 feature.state = OpenLayers.State.DELETE;
                                                                 layer.addFeatures([feature]);
                                                         }
                                                 });
                                          }
                                  }, "->", {
                                          text: "Guardar",
                                          handler: function() {
                                                 store.commitChanges();
                                                 saveStrategy.save();
                                          }
                                  }

                           ]
                   });                   
                   mapPanel.map.addControl(drawControl);

                   var modifyControl = new OpenLayers.Control.ModifyFeature(layer);
                   mapPanel.map.addControl(modifyControl);
                   modifyControl.activate();


                   /**************editorgrid*****************/
                   var   gridPanel = new Ext.grid.EditorGridPanel({
                   title: "Tabla de datos",
                   height: 150,
                   region:"south",
                   viewConfig: {forceFit: true},
                   store: store,
                   listeners: {
                                  afteredit: function(e) {
                                          var feature = e.record.get("feature");
                                          if(feature.state !== OpenLayers.State.INSERT) {
                                                 feature.state = OpenLayers.State.UPDATE;
                                          }
                                  }
                           },
                           sm: new GeoExt.grid.FeatureSelectionModel({
                                  selectControl: modifyControl.selectControl,
                                  singleSelect: true
                           }),
                           cm: new Ext.grid.ColumnModel({
                                  defaults: {
                                          sortable: true,
                                          editor: {xtype: "textfield"}
                                  },
                           columns: [{
                           id: "name",
                           header: "Name",
                           width: 200,
                           sortable: true,
                           dataIndex: "Name"
                   }]
     })
});
                   /*************************************/

    var layerList = new GeoExt.tree.LayerContainer({
                   text: 'Map Layers',
                   layerStore: mapPanel.layers,
                   leaf: false,
                   expanded: true
                   });

           var layerTree = new Ext.tree.TreePanel({
                           title: 'Map Layers',
                           maxWidth:500,
                           region: "west",
                           collapsible: true,
                           collapsed: false,
                           root: layerList
           });


         var mainPanel = new Ext.Panel({
             renderTo: document.body,
             layout: "border",
             height: 600,
             width:1430,
             items: [ mapPanel,gridPanel,layerTree]
         });
                    var point = new OpenLayers.LonLat(-65.4285, -16.97679);
          // Need to convert zoom point to mercator too
     point.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));       
         map.setCenter(point, 14);
     });
share|improve this question
2  
Are you getting any error? Can you see the response in Firebug? – Devdatta Tengshe Nov 16 '12 at 14:48
Yep, as first thing you should examine response for WFS-T query (there's short description of error, it may help, but probably it contains too few details) and error log of you WFS-T server (for much more detailed error description). – user1702401 Nov 16 '12 at 19:25

closed as not a real question by R.K., djq, Get Spatial, iant, Chad Cooper Nov 19 '12 at 15:10

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

You need to define the proxyhost to get xml(gml) data from geoserver. it is something like

OpenLayers.Proxyhost = "http:\\localhost\cgi-bin\proxy.cgi?url="
share|improve this answer
sorry for not responding i don't using proxy host because i'm using the same port and and i put the code in geoserver www folder do i need a proxy anyways? thanks for your advice – Alejandra Nov 19 '12 at 13:40
if you want to use same port/server then you should deploy the geoserver war file(.war) into a servlet(like tomcat) and access it through web server(like apache). if you are using jetty servlet(comes with the default windows installation) then you need to configure proxy. – byom Nov 19 '12 at 17:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.