source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/feature-grid.js
@
77
Revision 76, 2.2 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /** |
2 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
3 | * |
4 | * Published under the BSD license. |
5 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
6 | * of the license. |
7 | */ |
8 | |
9 | /** api: example[feature-grid] |
10 | * Grid with Features |
11 | * ------------------ |
12 | * Synchronize selection of features between a grid and a layer. |
13 | */ |
14 | |
15 | var mapPanel, store, gridPanel, mainPanel; |
16 | |
17 | Ext.onReady(function() { |
18 | // create map instance |
19 | var map = new OpenLayers.Map(); |
20 | var wmsLayer = new OpenLayers.Layer.WMS( |
21 | "vmap0", |
22 | "http://vmap0.tiles.osgeo.org/wms/vmap0", |
23 | {layers: 'basic'} |
24 | ); |
25 | |
26 | // create vector layer |
27 | var vecLayer = new OpenLayers.Layer.Vector("vector"); |
28 | map.addLayers([wmsLayer, vecLayer]); |
29 | |
30 | // create map panel |
31 | mapPanel = new GeoExt.MapPanel({ |
32 | title: "Map", |
33 | region: "center", |
34 | height: 400, |
35 | width: 600, |
36 | map: map, |
37 | center: new OpenLayers.LonLat(5, 45), |
38 | zoom: 6 |
39 | }); |
40 | |
41 | // create feature store, binding it to the vector layer |
42 | store = new GeoExt.data.FeatureStore({ |
43 | layer: vecLayer, |
44 | fields: [ |
45 | {name: 'name', type: 'string'}, |
46 | {name: 'elevation', type: 'float'} |
47 | ], |
48 | proxy: new GeoExt.data.ProtocolProxy({ |
49 | protocol: new OpenLayers.Protocol.HTTP({ |
50 | url: "data/summits.json", |
51 | format: new OpenLayers.Format.GeoJSON() |
52 | }) |
53 | }), |
54 | autoLoad: true |
55 | }); |
56 | |
57 | // create grid panel configured with feature store |
58 | gridPanel = new Ext.grid.GridPanel({ |
59 | title: "Feature Grid", |
60 | region: "east", |
61 | store: store, |
62 | width: 320, |
63 | columns: [{ |
64 | header: "Name", |
65 | width: 200, |
66 | dataIndex: "name" |
67 | }, { |
68 | header: "Elevation", |
69 | width: 100, |
70 | dataIndex: "elevation" |
71 | }], |
72 | sm: new GeoExt.grid.FeatureSelectionModel() |
73 | }); |
74 | |
75 | // create a panel and add the map panel and grid panel |
76 | // inside it |
77 | mainPanel = new Ext.Panel({ |
78 | renderTo: "mainpanel", |
79 | layout: "border", |
80 | height: 400, |
81 | width: 920, |
82 | items: [mapPanel, gridPanel] |
83 | }); |
84 | }); |
85 |
Note: See TracBrowser
for help on using the repository browser.