Merge branch 'master' of ssh://apples.lambdacomplex.org/git/bus
[bus.git] / openlayers / examples / wfs-t.html
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>OpenLayers: WFS-T</title>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="../lib/Firebug/firebug.js"></script>
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        var map, wfs;
        OpenLayers.ProxyHost = "proxy.cgi?url=";
 
        function init() {
            map = new OpenLayers.Map('map');
            var wms = new OpenLayers.Layer.WMS(
                "State",
                "http://sigma.openplans.org/geoserver/wms",
                {layers: 'topp:tasmania_state_boundaries'}
            );
            
            //
            // Word to the Wise from an anonymous OpenLayers hacker:
            //             
            // The typename in the options list when adding/loading a wfs 
            // layer not should contain the namespace before, (as in the 
            // first typename parameter to the wfs consctructor).
            // 
            // Specifically, in the first parameter you write typename: 
            // 'topp:myLayerName', and in the following option list 
            // typeName: 'myLayerName'. 
            // 
            // If you have topp included in the second one you will get 
            // namespace 14 errors when trying to insert features.
            //
            wfs = new OpenLayers.Layer.WFS(
                "Cities",
                "http://sigma.openplans.org/geoserver/wfs",
                {typename: 'topp:tasmania_cities'},
                {
                    typename: "tasmania_cities",
                    featureNS: "http://www.openplans.org/topp",
                    extractAttributes: false,
                    commitReport: function(str) {
                        OpenLayers.Console.log(str);
                    }
                }
            );
           
            map.addLayers([wms, wfs]);
 
            var panel = new OpenLayers.Control.Panel({
                displayClass: "olControlEditingToolbar"
            });
 
            var draw = new OpenLayers.Control.DrawFeature(
                wfs, OpenLayers.Handler.Point,
                {
                    handlerOptions: {freehand: false, multi: true},
                    displayClass: "olControlDrawFeaturePoint"
                }
            );
            
            var save = new OpenLayers.Control.Button({
                trigger: OpenLayers.Function.bind(wfs.commit, wfs),
                displayClass: "olControlSaveFeatures"
            });
           
            panel.addControls([
                new OpenLayers.Control.Navigation(),
                save, draw
            ]);
 
            map.addControl(panel);
            
            map.zoomToExtent(new OpenLayers.Bounds(140.64,-44.42,151.89,-38.80));
        }
        
    </script>
</head>
<body onload="init()">
 
    <h1 id="title">WFS Transaction Example</h1>
    
    <div id="tags">
    </div>
    <p id="shortdesc">
        Shows the use the WFS layer for transactions.
    </p>
    
    <div id="map" class="smallmap"></div>
    
    <p id="docs">
    This is an example of using a WFS layer type. Note that it requires a 
    working GeoServer install, which the OpenLayers project does not maintain;
    however, if you're interested, you should be able to point this against
    a default GeoServer setup without too much trouble.
    </p>
 
 
 
    </body>
</html>