wfs-t.html
3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map, layer;
function init(){
map = new OpenLayers.Map( $('map') );
layer = new OpenLayers.Layer.WMS( "State",
"http://dev.openlayers.org/geoserver/wms", {layers: 'topp:tasmania_state_boundaries'} );
map.addLayer(layer);
layer = new OpenLayers.Layer.WMS( "Water",
"http://dev.openlayers.org/geoserver/wms", {layers: 'topp:tasmania_water_bodies', 'transparent': true, format: 'image/gif' } );
map.addLayer(layer);
rlayer = new OpenLayers.Layer.WFS( "Roads",
"http://dev.openlayers.org/geoserver/wfs", {typename: 'topp:tasmania_roads'},
{
typename: 'tasmania_roads',
featureNS: 'http://www.openplans.org/topp',
extractAttributes: false
} );
rlayer.onFeatureInsert=function(feature) { feature.style.strokeColor = "#ff0000"; feature.layer.drawFeature(feature); }
map.addLayer(rlayer);
layer = new OpenLayers.Layer.WFS( "Cities",
"http://dev.openlayers.org/geoserver/wfs", {typename: 'topp:tasmania_cities'},
{
typename: 'tasmania_cities',
featureNS: 'http://www.openplans.org/topp',
extractAttributes: false
} );
map.addLayer(layer);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var p = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
df = new OpenLayers.Control.DrawFeature(rlayer, OpenLayers.Handler.Path, {handlerOptions: {'freehand': false}, 'displayClass': 'olControlDrawFeaturePath'});
df.featureAdded = function(feature) {
feature.state = OpenLayers.State.INSERT;
feature.style['strokeColor'] = "#0000ff";
feature.layer.drawFeature(feature);
}
dp = new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {handlerOptions: {'freehand': false}, 'displayClass': 'olControlDrawFeaturePoint'});
dp.featureAdded = function(feature) {
var oldgeom = feature.geometry;
feature.layer.renderer.eraseGeometry(oldgeom);
feature.geometry = new OpenLayers.Geometry.MultiPoint(oldgeom);
feature.state = OpenLayers.State.INSERT;
feature.style['strokeColor'] = "#0000ff";
feature.layer.drawFeature(feature);
}
p.addControls([ new OpenLayers.Control.Navigation(), df, dp ]);
map.addControl(p);
map.zoomToExtent(new OpenLayers.Bounds(145.51045,-44.0,149.0,-40.5));
}
// -->
</script>
</head>
<body onload="init()">
<a href="#" onclick="map.layers[2].commit();return false">Save Roads</a><br />
<a href="#" onclick="map.layers[3].commit();return false">Save Cities</a><br />
<div id="map"></div>
</body>
</html>