Database Reference
In-Depth Information
4. Now,inthescript,aftercreatingthemap,createan OpenStreetMap layer
that you will use in the map as the base layer, using the following code:
// create an OSM base layer
var osm = new OpenLayers.Layer.OSM();
5. Now,createtheWFS-Tlayer's OpenLayers objectusingthe StyleMap ob-
jecttorenderthePostGISlayerfeatureswithredpoints,asshowninthefol-
lowing screenshot:
// create the wfs layer
var saveStrategy = new
OpenLayers.Strategy.Save();
var wfs = new OpenLayers.Layer.Vector(
"Sites",
{
strategies: [new
OpenLayers.Strategy.BBOX(), saveStrategy],
projection: new
OpenLayers.Projection("EPSG:4326"),
styleMap: new OpenLayers.StyleMap({
pointRadius: 7,
fillColor: "#FF0000"
}),
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
srsName: "EPSG:4326",
url: "http://localhost:8080/geoserver/
wfs",
featurePrefix: 'postgis_cookbook',
featureType: "sites",
featureNS: "http://www.packtpub.com/
postgis-cookbook/book",
geometryName: "the_geom"
})
});
6. AddtheWFSlayertothemap,centeralignthemap,andsettheinitialzoom.
You can use the geometry transform method to convert a point from
Search WWH ::




Custom Search