Database Reference
In-Depth Information
EPSG:4326
,inwhichthelayerisstored,to
ESPG:900913
,whichisusedby
the viewer, as shown in the following code:
// add layers to map and center it
map.addLayers([osm, wfs]);
var fromProjection = new
OpenLayers.Projection("EPSG:4326");
var toProjection = new
OpenLayers.Projection("EPSG:900913");
var cpoint = new OpenLayers.LonLat(12.5,
41.85).transform( fromProjection,
toProjection);
map.setCenter(cpoint, 10);
7. Now,youwillcreateapanelwitha
Draw Point
tool(toaddnewfeatures)and
a
Save Features
tool(tosavethefeaturestotheunderlyingWFS-T).Wefirst
create the panel, as shown in the following code:
// create a panel for tools
var panel = new OpenLayers.Control.Panel({
displayClass:
"olControlEditingToolbar"
});
8. Now, we will create the
Draw Point
tool, as shown in the following code:
// create a draw point tool
var draw = new
OpenLayers.Control.DrawFeature(
wfs, OpenLayers.Handler.Point,
{
handlerOptions: {freehand: false,
multi: false},
displayClass:
"olControlDrawFeaturePoint"
}
);
9. Then, we will create the
Save Features
tool, using the following code: