1 | /** |
---|
2 | * Copyright (c) 2008-2009 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[attribute-form] |
---|
10 | * Attribute Form |
---|
11 | * -------------- |
---|
12 | * Create a form with fields from attributes read from a WFS |
---|
13 | * DescribeFeatureType response |
---|
14 | */ |
---|
15 | |
---|
16 | var form; |
---|
17 | |
---|
18 | Ext.onReady(function() { |
---|
19 | Ext.QuickTips.init(); |
---|
20 | |
---|
21 | // create attributes store |
---|
22 | var attributeStore = new GeoExt.data.AttributeStore({ |
---|
23 | url: "data/describe_feature_type.xml" |
---|
24 | }); |
---|
25 | |
---|
26 | form = new Ext.form.FormPanel({ |
---|
27 | renderTo: document.body, |
---|
28 | autoScroll: true, |
---|
29 | height: 300, |
---|
30 | width: 350, |
---|
31 | defaults: { |
---|
32 | width: 120, |
---|
33 | maxLengthText: "too long", |
---|
34 | minLengthText: "too short" |
---|
35 | }, |
---|
36 | plugins: [ |
---|
37 | new GeoExt.plugins.AttributeForm({ |
---|
38 | attributeStore: attributeStore |
---|
39 | }) |
---|
40 | ] |
---|
41 | }); |
---|
42 | |
---|
43 | attributeStore.load(); |
---|
44 | }); |
---|
45 | /** |
---|
46 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
47 | * |
---|
48 | * Published under the BSD license. |
---|
49 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
50 | * of the license. |
---|
51 | */ |
---|
52 | |
---|
53 | /** api: example[attributes] |
---|
54 | * Attribute Store & Reader |
---|
55 | * ------------------------ |
---|
56 | * Create records with attribute types and values with an AttributeStore. |
---|
57 | */ |
---|
58 | |
---|
59 | var store; |
---|
60 | Ext.onReady(function() { |
---|
61 | |
---|
62 | // create a new attributes store |
---|
63 | store = new GeoExt.data.AttributeStore({ |
---|
64 | url: "data/describe_feature_type.xml" |
---|
65 | }); |
---|
66 | store.load(); |
---|
67 | |
---|
68 | // create a grid to display records from the store |
---|
69 | var grid = new Ext.grid.GridPanel({ |
---|
70 | title: "Feature Attributes", |
---|
71 | store: store, |
---|
72 | cm: new Ext.grid.ColumnModel([ |
---|
73 | {id: "name", header: "Name", dataIndex: "name", sortable: true}, |
---|
74 | {id: "type", header: "Type", dataIndex: "type", sortable: true} |
---|
75 | ]), |
---|
76 | sm: new Ext.grid.RowSelectionModel({singleSelect:true}), |
---|
77 | autoExpandColumn: "name", |
---|
78 | renderTo: document.body, |
---|
79 | height: 300, |
---|
80 | width: 350 |
---|
81 | }); |
---|
82 | |
---|
83 | }); |
---|
84 | /** |
---|
85 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
86 | * |
---|
87 | * Published under the BSD license. |
---|
88 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
89 | * of the license. |
---|
90 | */ |
---|
91 | |
---|
92 | /** api: example[feature-grid] |
---|
93 | * Grid with Features |
---|
94 | * ------------------ |
---|
95 | * Synchronize selection of features between a grid and a layer. |
---|
96 | */ |
---|
97 | |
---|
98 | var mapPanel, store, gridPanel, mainPanel; |
---|
99 | |
---|
100 | Ext.onReady(function() { |
---|
101 | // create map instance |
---|
102 | var map = new OpenLayers.Map(); |
---|
103 | var wmsLayer = new OpenLayers.Layer.WMS( |
---|
104 | "vmap0", |
---|
105 | "http://vmap0.tiles.osgeo.org/wms/vmap0", |
---|
106 | {layers: 'basic'} |
---|
107 | ); |
---|
108 | |
---|
109 | // create vector layer |
---|
110 | var vecLayer = new OpenLayers.Layer.Vector("vector"); |
---|
111 | map.addLayers([wmsLayer, vecLayer]); |
---|
112 | |
---|
113 | // create map panel |
---|
114 | mapPanel = new GeoExt.MapPanel({ |
---|
115 | title: "Map", |
---|
116 | region: "center", |
---|
117 | height: 400, |
---|
118 | width: 600, |
---|
119 | map: map, |
---|
120 | center: new OpenLayers.LonLat(5, 45), |
---|
121 | zoom: 6 |
---|
122 | }); |
---|
123 | |
---|
124 | // create feature store, binding it to the vector layer |
---|
125 | store = new GeoExt.data.FeatureStore({ |
---|
126 | layer: vecLayer, |
---|
127 | fields: [ |
---|
128 | {name: 'name', type: 'string'}, |
---|
129 | {name: 'elevation', type: 'float'} |
---|
130 | ], |
---|
131 | proxy: new GeoExt.data.ProtocolProxy({ |
---|
132 | protocol: new OpenLayers.Protocol.HTTP({ |
---|
133 | url: "data/summits.json", |
---|
134 | format: new OpenLayers.Format.GeoJSON() |
---|
135 | }) |
---|
136 | }), |
---|
137 | autoLoad: true |
---|
138 | }); |
---|
139 | |
---|
140 | // create grid panel configured with feature store |
---|
141 | gridPanel = new Ext.grid.GridPanel({ |
---|
142 | title: "Feature Grid", |
---|
143 | region: "east", |
---|
144 | store: store, |
---|
145 | width: 320, |
---|
146 | columns: [{ |
---|
147 | header: "Name", |
---|
148 | width: 200, |
---|
149 | dataIndex: "name" |
---|
150 | }, { |
---|
151 | header: "Elevation", |
---|
152 | width: 100, |
---|
153 | dataIndex: "elevation" |
---|
154 | }], |
---|
155 | sm: new GeoExt.grid.FeatureSelectionModel() |
---|
156 | }); |
---|
157 | |
---|
158 | // create a panel and add the map panel and grid panel |
---|
159 | // inside it |
---|
160 | mainPanel = new Ext.Panel({ |
---|
161 | renderTo: "mainpanel", |
---|
162 | layout: "border", |
---|
163 | height: 400, |
---|
164 | width: 920, |
---|
165 | items: [mapPanel, gridPanel] |
---|
166 | }); |
---|
167 | }); |
---|
168 | |
---|
169 | /** |
---|
170 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
171 | * |
---|
172 | * Published under the BSD license. |
---|
173 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
174 | * of the license. |
---|
175 | */ |
---|
176 | |
---|
177 | /** api: example[layercontainer] |
---|
178 | * Layer Tree |
---|
179 | * ---------- |
---|
180 | * Create a layer tree with a LayerContainer. |
---|
181 | */ |
---|
182 | |
---|
183 | var store, tree, panel; |
---|
184 | Ext.onReady(function() { |
---|
185 | |
---|
186 | // create a new WMS capabilities store |
---|
187 | store = new GeoExt.data.WMSCapabilitiesStore({ |
---|
188 | url: "data/wmscap.xml" |
---|
189 | }); |
---|
190 | // load the store with records derived from the doc at the above url |
---|
191 | store.load(); |
---|
192 | |
---|
193 | // create a grid to display records from the store |
---|
194 | var grid = new Ext.grid.GridPanel({ |
---|
195 | title: "WMS Capabilities", |
---|
196 | store: store, |
---|
197 | cm: new Ext.grid.ColumnModel([ |
---|
198 | {header: "Name", dataIndex: "name", sortable: true}, |
---|
199 | {id: "title", header: "Title", dataIndex: "title", sortable: true} |
---|
200 | ]), |
---|
201 | sm: new Ext.grid.RowSelectionModel({singleSelect:true}), |
---|
202 | autoExpandColumn: "title", |
---|
203 | renderTo: "capgrid", |
---|
204 | height: 300, |
---|
205 | width: 350, |
---|
206 | floating: true, |
---|
207 | x: 10, |
---|
208 | y: 0, |
---|
209 | bbar: ["->", { |
---|
210 | text: "Add Layer", |
---|
211 | handler: function() { |
---|
212 | var record = grid.getSelectionModel().getSelected(); |
---|
213 | if(record) { |
---|
214 | var copy = record.copy(); |
---|
215 | // Ext 3.X does not allow circular references in objects passed |
---|
216 | // to record.set |
---|
217 | copy.data["layer"] = record.getLayer(); |
---|
218 | copy.getLayer().mergeNewParams({ |
---|
219 | format: "image/png", |
---|
220 | transparent: "true" |
---|
221 | }); |
---|
222 | panel.layers.add(copy); |
---|
223 | panel.map.zoomToExtent( |
---|
224 | OpenLayers.Bounds.fromArray(copy.get("llbbox")) |
---|
225 | ); |
---|
226 | } |
---|
227 | } |
---|
228 | }] |
---|
229 | }); |
---|
230 | |
---|
231 | // create a map panel |
---|
232 | panel = new GeoExt.MapPanel({ |
---|
233 | renderTo: "mappanel", |
---|
234 | width: 350, |
---|
235 | height: 300, |
---|
236 | floating: true, |
---|
237 | x: 570, |
---|
238 | y: 0 |
---|
239 | }); |
---|
240 | |
---|
241 | tree = new Ext.tree.TreePanel({ |
---|
242 | renderTo: "tree", |
---|
243 | root: new GeoExt.tree.LayerContainer({ |
---|
244 | text: 'Map Layers', |
---|
245 | layerStore: panel.layers, |
---|
246 | leaf: false, |
---|
247 | expanded: true |
---|
248 | }), |
---|
249 | enableDD: true, |
---|
250 | width: 170, |
---|
251 | height: 300, |
---|
252 | floating: true, |
---|
253 | x: 380, |
---|
254 | y: 0 |
---|
255 | }); |
---|
256 | |
---|
257 | |
---|
258 | }); |
---|
259 | /** |
---|
260 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
261 | * |
---|
262 | * Published under the BSD license. |
---|
263 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
264 | * of the license. |
---|
265 | */ |
---|
266 | |
---|
267 | /** api: example[layeropacityslider] |
---|
268 | * Layer Opacity Slider |
---|
269 | * -------------------- |
---|
270 | * Use a slider to control layer opacity. |
---|
271 | */ |
---|
272 | |
---|
273 | var panel1, panel2, wms, slider; |
---|
274 | |
---|
275 | Ext.onReady(function() { |
---|
276 | |
---|
277 | wms = new OpenLayers.Layer.WMS( |
---|
278 | "Global Imagery", |
---|
279 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
280 | {layers: "bluemarble"} |
---|
281 | ); |
---|
282 | |
---|
283 | // create a map panel with an embedded slider |
---|
284 | panel1 = new GeoExt.MapPanel({ |
---|
285 | title: "Map 1", |
---|
286 | renderTo: "map1-container", |
---|
287 | height: 300, |
---|
288 | width: 400, |
---|
289 | map: { |
---|
290 | controls: [new OpenLayers.Control.Navigation()] |
---|
291 | }, |
---|
292 | layers: [wms], |
---|
293 | extent: [-5, 35, 15, 55], |
---|
294 | items: [{ |
---|
295 | xtype: "gx_opacityslider", |
---|
296 | layer: wms, |
---|
297 | vertical: true, |
---|
298 | height: 120, |
---|
299 | x: 10, |
---|
300 | y: 10, |
---|
301 | plugins: new GeoExt.LayerOpacitySliderTip({template: '<div>Opacity: {opacity}%</div>'}) |
---|
302 | }] |
---|
303 | }); |
---|
304 | // create a separate slider bound to the map but displayed elsewhere |
---|
305 | slider = new GeoExt.LayerOpacitySlider({ |
---|
306 | layer: wms, |
---|
307 | aggressive: true, |
---|
308 | width: 200, |
---|
309 | isFormField: true, |
---|
310 | inverse: true, |
---|
311 | fieldLabel: "opacity", |
---|
312 | renderTo: "slider", |
---|
313 | plugins: new GeoExt.LayerOpacitySliderTip({template: '<div>Transparency: {opacity}%</div>'}) |
---|
314 | }); |
---|
315 | |
---|
316 | var clone = wms.clone(); |
---|
317 | var wms2 = new OpenLayers.Layer.WMS( |
---|
318 | "OpenLayers WMS", |
---|
319 | "http://vmap0.tiles.osgeo.org/wms/vmap0", |
---|
320 | {layers: 'basic'} |
---|
321 | ); |
---|
322 | panel2 = new GeoExt.MapPanel({ |
---|
323 | title: "Map 2", |
---|
324 | renderTo: "map2-container", |
---|
325 | height: 300, |
---|
326 | width: 400, |
---|
327 | map: { |
---|
328 | controls: [new OpenLayers.Control.Navigation()] |
---|
329 | }, |
---|
330 | layers: [wms2, clone], |
---|
331 | extent: [-5, 35, 15, 55], |
---|
332 | items: [{ |
---|
333 | xtype: "gx_opacityslider", |
---|
334 | layer: clone, |
---|
335 | complementaryLayer: wms2, |
---|
336 | changeVisibility: true, |
---|
337 | aggressive: true, |
---|
338 | vertical: true, |
---|
339 | height: 120, |
---|
340 | x: 10, |
---|
341 | y: 10, |
---|
342 | plugins: new GeoExt.LayerOpacitySliderTip() |
---|
343 | }] |
---|
344 | }); |
---|
345 | |
---|
346 | var tree = new Ext.tree.TreePanel({ |
---|
347 | width: 145, |
---|
348 | height: 300, |
---|
349 | renderTo: "tree", |
---|
350 | root: new GeoExt.tree.LayerContainer({ |
---|
351 | layerStore: panel2.layers, |
---|
352 | expanded: true |
---|
353 | }) |
---|
354 | }); |
---|
355 | |
---|
356 | }); |
---|
357 | /** |
---|
358 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
359 | * |
---|
360 | * Published under the BSD license. |
---|
361 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
362 | * of the license. |
---|
363 | */ |
---|
364 | |
---|
365 | /** api: example[legendpanel] |
---|
366 | * Legend Panel |
---|
367 | * ------------ |
---|
368 | * Display a layer legend in a panel. |
---|
369 | */ |
---|
370 | |
---|
371 | |
---|
372 | var mapPanel, legendPanel; |
---|
373 | |
---|
374 | Ext.onReady(function() { |
---|
375 | var map = new OpenLayers.Map({allOverlays: true}); |
---|
376 | map.addLayers([ |
---|
377 | new OpenLayers.Layer.WMS( |
---|
378 | "Tasmania", |
---|
379 | "http://demo.opengeo.org/geoserver/wms?", |
---|
380 | {layers: 'topp:tasmania_state_boundaries', format: 'image/png', transparent: true}, |
---|
381 | {singleTile: true}), |
---|
382 | new OpenLayers.Layer.WMS( |
---|
383 | "Cities and Roads", |
---|
384 | "http://demo.opengeo.org/geoserver/wms?", |
---|
385 | {layers: 'topp:tasmania_cities,topp:tasmania_roads', format: 'image/png', transparent: true}, |
---|
386 | {singleTile: true}), |
---|
387 | new OpenLayers.Layer.Vector('Polygons', {styleMap: new OpenLayers.StyleMap({ |
---|
388 | "default": new OpenLayers.Style({ |
---|
389 | pointRadius: 8, |
---|
390 | fillColor: "#00ffee", |
---|
391 | strokeColor: "#000000", |
---|
392 | strokeWidth: 2 |
---|
393 | }) }) }) |
---|
394 | ]); |
---|
395 | map.layers[2].addFeatures([ |
---|
396 | new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT( |
---|
397 | "POLYGON(146.1 -41, 146.2 -41, 146.2 -41.1, 146.1 -41.1)")) |
---|
398 | ]); |
---|
399 | map.addControl(new OpenLayers.Control.LayerSwitcher()); |
---|
400 | |
---|
401 | var addRemoveLayer = function() { |
---|
402 | if(mapPanel.map.layers.indexOf(water) == -1) { |
---|
403 | mapPanel.map.addLayer(water); |
---|
404 | } else { |
---|
405 | mapPanel.map.removeLayer(water); |
---|
406 | } |
---|
407 | }; |
---|
408 | |
---|
409 | var moveLayer = function(idx) { |
---|
410 | var layer = layerRec0.getLayer(); |
---|
411 | var idx = mapPanel.map.layers.indexOf(layer) == 0 ? |
---|
412 | mapPanel.map.layers.length : 0; |
---|
413 | mapPanel.map.setLayerIndex(layerRec0.getLayer(), idx); |
---|
414 | }; |
---|
415 | |
---|
416 | var toggleVisibility = function() { |
---|
417 | var layer = layerRec1.getLayer(); |
---|
418 | layer.setVisibility(!layer.getVisibility()); |
---|
419 | }; |
---|
420 | |
---|
421 | var updateHideInLegend = function() { |
---|
422 | layerRec0.set("hideInLegend", !layerRec0.get("hideInLegend")); |
---|
423 | }; |
---|
424 | |
---|
425 | var updateLegendUrl = function() { |
---|
426 | var url = layerRec0.get("legendURL"); |
---|
427 | layerRec0.set("legendURL", otherUrl); |
---|
428 | otherUrl = url; |
---|
429 | }; |
---|
430 | |
---|
431 | mapPanel = new GeoExt.MapPanel({ |
---|
432 | region: 'center', |
---|
433 | height: 400, |
---|
434 | width: 600, |
---|
435 | map: map, |
---|
436 | center: new OpenLayers.LonLat(146.4, -41.6), |
---|
437 | zoom: 7 |
---|
438 | }); |
---|
439 | |
---|
440 | // give the record of the 1st layer a legendURL, which will cause |
---|
441 | // UrlLegend instead of WMSLegend to be used |
---|
442 | var layerRec0 = mapPanel.layers.getAt(0); |
---|
443 | layerRec0.set("legendURL", "http://demo.opengeo.org/geoserver/wms?FORMAT=image%2Fgif&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&LAYER=topp%3Atasmania_state_boundaries"); |
---|
444 | |
---|
445 | // store the layer that we will modify in toggleVis() |
---|
446 | var layerRec1 = mapPanel.layers.getAt(1); |
---|
447 | |
---|
448 | // stores another legendURL for the legendurl button action |
---|
449 | var otherUrl = "http://www.geoext.org/trac/geoext/chrome/site/img/GeoExt.png"; |
---|
450 | |
---|
451 | // create another layer for the add/remove button action |
---|
452 | var water = new OpenLayers.Layer.WMS("Bodies of Water", |
---|
453 | "http://demo.opengeo.org/geoserver/wms?", |
---|
454 | {layers: 'topp:tasmania_water_bodies', format: 'image/png', transparent: true}, |
---|
455 | {singleTile: true}); |
---|
456 | |
---|
457 | legendPanel = new GeoExt.LegendPanel({ |
---|
458 | defaults: { |
---|
459 | labelCls: 'mylabel', |
---|
460 | style: 'padding:5px' |
---|
461 | }, |
---|
462 | bodyStyle: 'padding:5px', |
---|
463 | width: 350, |
---|
464 | autoScroll: true, |
---|
465 | region: 'west' |
---|
466 | }); |
---|
467 | |
---|
468 | new Ext.Panel({ |
---|
469 | title: "GeoExt LegendPanel Demo", |
---|
470 | layout: 'border', |
---|
471 | renderTo: 'view', |
---|
472 | height: 400, |
---|
473 | width: 800, |
---|
474 | tbar: new Ext.Toolbar({ |
---|
475 | items: [ |
---|
476 | {text: 'add/remove', handler: addRemoveLayer}, |
---|
477 | {text: 'movetop/bottom', handler: moveLayer }, |
---|
478 | {text: 'togglevis', handler: toggleVisibility}, |
---|
479 | {text: 'hide/show', handler: updateHideInLegend}, |
---|
480 | {text: 'legendurl', handler: updateLegendUrl} |
---|
481 | ] |
---|
482 | }), |
---|
483 | items: [legendPanel, mapPanel] |
---|
484 | }); |
---|
485 | }); |
---|
486 | /** |
---|
487 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
488 | * |
---|
489 | * Published under the BSD license. |
---|
490 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
491 | * of the license. |
---|
492 | */ |
---|
493 | |
---|
494 | /** api: example[mappanel-div] |
---|
495 | * Map Panel |
---|
496 | * --------- |
---|
497 | * Render a map panel in any block level page element. |
---|
498 | */ |
---|
499 | |
---|
500 | var mapPanel; |
---|
501 | |
---|
502 | Ext.onReady(function() { |
---|
503 | Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); |
---|
504 | var map = new OpenLayers.Map(); |
---|
505 | var layer = new OpenLayers.Layer.WMS( |
---|
506 | "Global Imagery", |
---|
507 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
508 | {layers: "bluemarble"} |
---|
509 | ); |
---|
510 | map.addLayer(layer); |
---|
511 | |
---|
512 | mapPanel = new GeoExt.MapPanel({ |
---|
513 | title: "GeoExt MapPanel", |
---|
514 | renderTo: "mappanel", |
---|
515 | stateId: "mappanel", |
---|
516 | height: 400, |
---|
517 | width: 600, |
---|
518 | map: map, |
---|
519 | center: new OpenLayers.LonLat(5, 45), |
---|
520 | zoom: 4, |
---|
521 | // getState and applyState are overloaded so panel size |
---|
522 | // can be stored and restored |
---|
523 | getState: function() { |
---|
524 | var state = GeoExt.MapPanel.prototype.getState.apply(this); |
---|
525 | state.width = this.getSize().width; |
---|
526 | state.height = this.getSize().height; |
---|
527 | return state; |
---|
528 | }, |
---|
529 | applyState: function(state) { |
---|
530 | GeoExt.MapPanel.prototype.applyState.apply(this, arguments); |
---|
531 | this.width = state.width; |
---|
532 | this.height = state.height; |
---|
533 | } |
---|
534 | }); |
---|
535 | }); |
---|
536 | |
---|
537 | // functions for resizing the map panel |
---|
538 | function mapSizeUp() { |
---|
539 | var size = mapPanel.getSize(); |
---|
540 | size.width += 40; |
---|
541 | size.height += 40; |
---|
542 | mapPanel.setSize(size); |
---|
543 | } |
---|
544 | function mapSizeDown() { |
---|
545 | var size = mapPanel.getSize(); |
---|
546 | size.width -= 40; |
---|
547 | size.height -= 40; |
---|
548 | mapPanel.setSize(size); |
---|
549 | } |
---|
550 | |
---|
551 | /** |
---|
552 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
553 | * |
---|
554 | * Published under the BSD license. |
---|
555 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
556 | * of the license. |
---|
557 | */ |
---|
558 | |
---|
559 | /** api: example[mappanel-viewport] |
---|
560 | * Map Panel (in a Viewport) |
---|
561 | * ------------------------- |
---|
562 | * Render a map panel in a viewport. |
---|
563 | */ |
---|
564 | |
---|
565 | var mapPanel; |
---|
566 | |
---|
567 | Ext.onReady(function() { |
---|
568 | |
---|
569 | // if true a google layer is used, if false |
---|
570 | // the bluemarble WMS layer is used |
---|
571 | var google = false; |
---|
572 | |
---|
573 | var options, layer; |
---|
574 | var extent = new OpenLayers.Bounds(-5, 35, 15, 55); |
---|
575 | |
---|
576 | if (google) { |
---|
577 | |
---|
578 | options = { |
---|
579 | projection: new OpenLayers.Projection("EPSG:900913"), |
---|
580 | units: "m", |
---|
581 | numZoomLevels: 18, |
---|
582 | maxResolution: 156543.0339, |
---|
583 | maxExtent: new OpenLayers.Bounds(-20037508, -20037508, |
---|
584 | 20037508, 20037508.34) |
---|
585 | }; |
---|
586 | |
---|
587 | layer = new OpenLayers.Layer.Google( |
---|
588 | "Google Satellite", |
---|
589 | {type: G_SATELLITE_MAP, sphericalMercator: true} |
---|
590 | ); |
---|
591 | |
---|
592 | extent.transform( |
---|
593 | new OpenLayers.Projection("EPSG:4326"), options.projection |
---|
594 | ); |
---|
595 | |
---|
596 | } else { |
---|
597 | layer = new OpenLayers.Layer.WMS( |
---|
598 | "Global Imagery", |
---|
599 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
600 | {layers: "bluemarble"}, |
---|
601 | {isBaseLayer: true} |
---|
602 | ); |
---|
603 | } |
---|
604 | |
---|
605 | var map = new OpenLayers.Map(options); |
---|
606 | |
---|
607 | new Ext.Viewport({ |
---|
608 | layout: "border", |
---|
609 | items: [{ |
---|
610 | region: "north", |
---|
611 | contentEl: "title", |
---|
612 | height: 50 |
---|
613 | }, { |
---|
614 | region: "center", |
---|
615 | id: "mappanel", |
---|
616 | title: "Map", |
---|
617 | xtype: "gx_mappanel", |
---|
618 | map: map, |
---|
619 | layers: [layer], |
---|
620 | extent: extent, |
---|
621 | split: true |
---|
622 | }, { |
---|
623 | region: "east", |
---|
624 | title: "Description", |
---|
625 | contentEl: "description", |
---|
626 | width: 200, |
---|
627 | split: true |
---|
628 | }] |
---|
629 | }); |
---|
630 | |
---|
631 | mapPanel = Ext.getCmp("mappanel"); |
---|
632 | }); |
---|
633 | /** |
---|
634 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
635 | * |
---|
636 | * Published under the BSD license. |
---|
637 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
638 | * of the license. |
---|
639 | */ |
---|
640 | |
---|
641 | /** api: example[mappanel-window] |
---|
642 | * Map Panel (in a Window) |
---|
643 | * ------------------------- |
---|
644 | * Render a map panel in a Window. |
---|
645 | */ |
---|
646 | |
---|
647 | var mapPanel; |
---|
648 | |
---|
649 | Ext.onReady(function() { |
---|
650 | new Ext.Window({ |
---|
651 | title: "GeoExt MapPanel Window", |
---|
652 | height: 400, |
---|
653 | width: 600, |
---|
654 | layout: "fit", |
---|
655 | items: [{ |
---|
656 | xtype: "gx_mappanel", |
---|
657 | id: "mappanel", |
---|
658 | layers: [new OpenLayers.Layer.WMS( |
---|
659 | "Global Imagery", |
---|
660 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
661 | {layers: "bluemarble"} |
---|
662 | )], |
---|
663 | extent: "-5,35,15,55" |
---|
664 | }] |
---|
665 | }).show(); |
---|
666 | |
---|
667 | mapPanel = Ext.getCmp("mappanel"); |
---|
668 | }); |
---|
669 | /** |
---|
670 | * Copyright (c) 2008-2009 The Open Source Geospatial Foundation |
---|
671 | * |
---|
672 | * Published under the BSD license. |
---|
673 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
674 | * of the license. |
---|
675 | */ |
---|
676 | |
---|
677 | /** api: example[permalink] |
---|
678 | * Permalink |
---|
679 | * --------- |
---|
680 | * Display a permalink each time the map changes position. |
---|
681 | */ |
---|
682 | |
---|
683 | var permalinkProvider; |
---|
684 | |
---|
685 | Ext.onReady(function() { |
---|
686 | |
---|
687 | // set a permalink provider |
---|
688 | permalinkProvider = new GeoExt.state.PermalinkProvider({encodeType: false}); |
---|
689 | Ext.state.Manager.setProvider(permalinkProvider); |
---|
690 | |
---|
691 | var map = new OpenLayers.Map(); |
---|
692 | map.addLayers([ |
---|
693 | new OpenLayers.Layer.WMS( |
---|
694 | "Imagery", |
---|
695 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
696 | {layers: "bluemarble"} |
---|
697 | ), |
---|
698 | new OpenLayers.Layer.WMS( |
---|
699 | "OSM", |
---|
700 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
701 | {layers: "openstreetmap"} |
---|
702 | ) |
---|
703 | ]); |
---|
704 | map.addControl(new OpenLayers.Control.LayerSwitcher()); |
---|
705 | |
---|
706 | var mapPanel = new GeoExt.MapPanel({ |
---|
707 | title: "GeoExt MapPanel", |
---|
708 | renderTo: "mappanel", |
---|
709 | height: 400, |
---|
710 | width: 600, |
---|
711 | map: map, |
---|
712 | center: new OpenLayers.LonLat(5, 45), |
---|
713 | zoom: 4, |
---|
714 | stateId: "map", |
---|
715 | prettyStateKeys: true |
---|
716 | }); |
---|
717 | |
---|
718 | // update link when state chnages |
---|
719 | var onStatechange = function(provider) { |
---|
720 | var l = provider.getLink(); |
---|
721 | Ext.get("permalink").update("<a href=" + l + ">" + l + "</a>"); |
---|
722 | }; |
---|
723 | permalinkProvider.on({statechange: onStatechange}); |
---|
724 | }); |
---|
725 | /** |
---|
726 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
727 | * |
---|
728 | * Published under the BSD license. |
---|
729 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
730 | * of the license. |
---|
731 | */ |
---|
732 | |
---|
733 | /** api: example[popup-more] |
---|
734 | * Modifying Popups |
---|
735 | * ---------------- |
---|
736 | * Update a popup with information from multiple locations. |
---|
737 | */ |
---|
738 | |
---|
739 | var mapPanel, popup; |
---|
740 | |
---|
741 | Ext.onReady(function() { |
---|
742 | |
---|
743 | function addToPopup(loc) { |
---|
744 | |
---|
745 | // create the popup if it doesn't exist |
---|
746 | if (!popup) { |
---|
747 | popup = new GeoExt.Popup({ |
---|
748 | title: "Popup", |
---|
749 | width: 200, |
---|
750 | maximizable: true, |
---|
751 | collapsible: true, |
---|
752 | map: mapPanel.map, |
---|
753 | anchored: true, |
---|
754 | listeners: { |
---|
755 | close: function() { |
---|
756 | // closing a popup destroys it, but our reference is truthy |
---|
757 | popup = null; |
---|
758 | } |
---|
759 | } |
---|
760 | }); |
---|
761 | } |
---|
762 | |
---|
763 | // add some content to the popup (this can be any Ext component) |
---|
764 | popup.add({ |
---|
765 | xtype: "box", |
---|
766 | autoEl: { |
---|
767 | html: "You clicked on (" + loc.lon.toFixed(2) + ", " + loc.lat.toFixed(2) + ")" |
---|
768 | } |
---|
769 | }); |
---|
770 | |
---|
771 | // reset the popup's location |
---|
772 | popup.location = loc; |
---|
773 | |
---|
774 | popup.doLayout(); |
---|
775 | |
---|
776 | // since the popup is anchored, calling show will move popup to this location |
---|
777 | popup.show(); |
---|
778 | } |
---|
779 | |
---|
780 | // create Ext window including a map panel |
---|
781 | var mapPanel = new GeoExt.MapPanel({ |
---|
782 | title: "Map", |
---|
783 | renderTo: "container", |
---|
784 | width: 650, height: 356, |
---|
785 | layers: [ |
---|
786 | new OpenLayers.Layer.WMS( |
---|
787 | "Global Imagery", |
---|
788 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
789 | {layers: "bluemarble"} |
---|
790 | ) |
---|
791 | ], |
---|
792 | center: [0, 0], |
---|
793 | zoom: 2 |
---|
794 | }); |
---|
795 | |
---|
796 | var control = new OpenLayers.Control.Click({ |
---|
797 | trigger: function(evt) { |
---|
798 | var loc = mapPanel.map.getLonLatFromViewPortPx(evt.xy); |
---|
799 | addToPopup(loc); |
---|
800 | } |
---|
801 | }); |
---|
802 | |
---|
803 | mapPanel.map.addControl(control); |
---|
804 | control.activate(); |
---|
805 | |
---|
806 | }); |
---|
807 | |
---|
808 | // simple control to handle user clicks on the map |
---|
809 | |
---|
810 | OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { |
---|
811 | |
---|
812 | defaultHandlerOptions: { |
---|
813 | single: true, |
---|
814 | double: false, |
---|
815 | pixelTolerance: 0, |
---|
816 | stopSingle: true |
---|
817 | }, |
---|
818 | |
---|
819 | initialize: function(options) { |
---|
820 | |
---|
821 | this.handlerOptions = OpenLayers.Util.extend( |
---|
822 | options && options.handlerOptions || {}, |
---|
823 | this.defaultHandlerOptions |
---|
824 | ); |
---|
825 | OpenLayers.Control.prototype.initialize.apply( |
---|
826 | this, arguments |
---|
827 | ); |
---|
828 | this.handler = new OpenLayers.Handler.Click( |
---|
829 | this, |
---|
830 | { |
---|
831 | click: this.trigger |
---|
832 | }, |
---|
833 | this.handlerOptions |
---|
834 | ); |
---|
835 | }, |
---|
836 | |
---|
837 | CLASS_NAME: "OpenLayers.Control.Click" |
---|
838 | |
---|
839 | }); |
---|
840 | /** |
---|
841 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
842 | * |
---|
843 | * Published under the BSD license. |
---|
844 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
845 | * of the license. |
---|
846 | */ |
---|
847 | |
---|
848 | /** api: example[popup] |
---|
849 | * Feature Popup |
---|
850 | * ------------- |
---|
851 | * Display a popup with feature information. |
---|
852 | */ |
---|
853 | |
---|
854 | var mapPanel, popup; |
---|
855 | |
---|
856 | Ext.onReady(function() { |
---|
857 | |
---|
858 | // create a vector layer, add a feature into it |
---|
859 | var vectorLayer = new OpenLayers.Layer.Vector("vector"); |
---|
860 | vectorLayer.addFeatures( |
---|
861 | new OpenLayers.Feature.Vector( |
---|
862 | new OpenLayers.Geometry.Point(-45, 5) |
---|
863 | ) |
---|
864 | ); |
---|
865 | |
---|
866 | // create select feature control |
---|
867 | var selectCtrl = new OpenLayers.Control.SelectFeature(vectorLayer); |
---|
868 | |
---|
869 | // define "createPopup" function |
---|
870 | var bogusMarkup = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit."; |
---|
871 | function createPopup(feature) { |
---|
872 | popup = new GeoExt.Popup({ |
---|
873 | title: 'My Popup', |
---|
874 | location: feature, |
---|
875 | width:200, |
---|
876 | html: bogusMarkup, |
---|
877 | maximizable: true, |
---|
878 | collapsible: true |
---|
879 | }); |
---|
880 | // unselect feature when the popup |
---|
881 | // is closed |
---|
882 | popup.on({ |
---|
883 | close: function() { |
---|
884 | if(OpenLayers.Util.indexOf(vectorLayer.selectedFeatures, |
---|
885 | this.feature) > -1) { |
---|
886 | selectCtrl.unselect(this.feature); |
---|
887 | } |
---|
888 | } |
---|
889 | }); |
---|
890 | popup.show(); |
---|
891 | } |
---|
892 | |
---|
893 | // create popup on "featureselected" |
---|
894 | vectorLayer.events.on({ |
---|
895 | featureselected: function(e) { |
---|
896 | createPopup(e.feature); |
---|
897 | } |
---|
898 | }); |
---|
899 | |
---|
900 | // create Ext window including a map panel |
---|
901 | var mapwin = new Ext.Window({ |
---|
902 | layout: "fit", |
---|
903 | title: "Map", |
---|
904 | closeAction: "hide", |
---|
905 | width: 650, |
---|
906 | height: 356, |
---|
907 | x: 50, |
---|
908 | y: 100, |
---|
909 | items: { |
---|
910 | xtype: "gx_mappanel", |
---|
911 | region: "center", |
---|
912 | layers: [ |
---|
913 | new OpenLayers.Layer.WMS( |
---|
914 | "OpenLayers WMS", |
---|
915 | "http://vmap0.tiles.osgeo.org/wms/vmap0", |
---|
916 | {layers: 'basic'} ), |
---|
917 | vectorLayer |
---|
918 | ] |
---|
919 | } |
---|
920 | }); |
---|
921 | mapwin.show(); |
---|
922 | |
---|
923 | mapPanel = mapwin.items.get(0); |
---|
924 | mapPanel.map.addControl(selectCtrl); |
---|
925 | selectCtrl.activate(); |
---|
926 | }); |
---|
927 | /** |
---|
928 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
929 | * |
---|
930 | * Published under the BSD license. |
---|
931 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
932 | * of the license. |
---|
933 | */ |
---|
934 | |
---|
935 | /** api: example[print-extent] |
---|
936 | * Interactive Print Extent |
---|
937 | * ------------------------ |
---|
938 | * Change print scale, center and rotation with the PrintExtent plugin. |
---|
939 | */ |
---|
940 | |
---|
941 | var mapPanel, printProvider; |
---|
942 | |
---|
943 | Ext.onReady(function() { |
---|
944 | // The printProvider that connects us to the print service |
---|
945 | printProvider = new GeoExt.data.PrintProvider({ |
---|
946 | method: "GET", // "POST" recommended for production use |
---|
947 | capabilities: printCapabilities, // from the info.json script in the html |
---|
948 | customParams: { |
---|
949 | mapTitle: "Printing Demo", |
---|
950 | comment: "This is a map printed from GeoExt." |
---|
951 | } |
---|
952 | }); |
---|
953 | |
---|
954 | var printExtent = new GeoExt.plugins.PrintExtent({ |
---|
955 | printProvider: printProvider |
---|
956 | }); |
---|
957 | |
---|
958 | // The map we want to print, with the PrintExtent added as item. |
---|
959 | mapPanel = new GeoExt.MapPanel({ |
---|
960 | renderTo: "content", |
---|
961 | width: 450, |
---|
962 | height: 320, |
---|
963 | layers: [new OpenLayers.Layer.WMS("Tasmania", "http://demo.opengeo.org/geoserver/wms", |
---|
964 | {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})], |
---|
965 | center: [146.56, -41.56], |
---|
966 | zoom: 6, |
---|
967 | plugins: [printExtent], |
---|
968 | bbar: [{ |
---|
969 | text: "Create PDF", |
---|
970 | handler: function() { |
---|
971 | // the PrintExtent plugin is the mapPanel's 1st plugin |
---|
972 | mapPanel.plugins[0].print(); |
---|
973 | } |
---|
974 | }] |
---|
975 | }); |
---|
976 | printExtent.addPage(); |
---|
977 | }); |
---|
978 | /** |
---|
979 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
980 | * |
---|
981 | * Published under the BSD license. |
---|
982 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
983 | * of the license. |
---|
984 | */ |
---|
985 | |
---|
986 | /** api: example[print-form] |
---|
987 | * Print Configuration with a Form |
---|
988 | * ------------------------------- |
---|
989 | * Use form field plugins to control print output. |
---|
990 | */ |
---|
991 | |
---|
992 | var mapPanel, printPage; |
---|
993 | |
---|
994 | Ext.onReady(function() { |
---|
995 | // The printProvider that connects us to the print service |
---|
996 | var printProvider = new GeoExt.data.PrintProvider({ |
---|
997 | method: "GET", // "POST" recommended for production use |
---|
998 | capabilities: printCapabilities, // from the info.json script in the html |
---|
999 | customParams: { |
---|
1000 | mapTitle: "Printing Demo" |
---|
1001 | } |
---|
1002 | }); |
---|
1003 | // Our print page. Stores scale, center and rotation and gives us a page |
---|
1004 | // extent feature that we can add to a layer. |
---|
1005 | printPage = new GeoExt.data.PrintPage({ |
---|
1006 | printProvider: printProvider |
---|
1007 | }); |
---|
1008 | // A layer to display the print page extent |
---|
1009 | var pageLayer = new OpenLayers.Layer.Vector(); |
---|
1010 | pageLayer.addFeatures(printPage.feature); |
---|
1011 | |
---|
1012 | // The map we want to print |
---|
1013 | mapPanel = new GeoExt.MapPanel({ |
---|
1014 | region: "center", |
---|
1015 | map: { |
---|
1016 | eventListeners: { |
---|
1017 | // recenter/resize page extent after pan/zoom |
---|
1018 | "moveend": function(){ printPage.fit(this, {mode: "screen"}); } |
---|
1019 | } |
---|
1020 | }, |
---|
1021 | layers: [ |
---|
1022 | new OpenLayers.Layer.WMS("Tasmania", "http://demo.opengeo.org/geoserver/wms", |
---|
1023 | {layers: "topp:tasmania_state_boundaries"}, {singleTile: true}), |
---|
1024 | pageLayer |
---|
1025 | ], |
---|
1026 | center: [146.56, -41.56], |
---|
1027 | zoom: 6 |
---|
1028 | }); |
---|
1029 | // The form with fields controlling the print output |
---|
1030 | var formPanel = new Ext.form.FormPanel({ |
---|
1031 | region: "west", |
---|
1032 | width: 150, |
---|
1033 | bodyStyle: "padding:5px", |
---|
1034 | labelAlign: "top", |
---|
1035 | defaults: {anchor: "100%"}, |
---|
1036 | items: [{ |
---|
1037 | xtype: "textarea", |
---|
1038 | name: "comment", |
---|
1039 | value: "", |
---|
1040 | fieldLabel: "Comment", |
---|
1041 | plugins: new GeoExt.plugins.PrintPageField({ |
---|
1042 | printPage: printPage |
---|
1043 | }) |
---|
1044 | }, { |
---|
1045 | xtype: "combo", |
---|
1046 | store: printProvider.layouts, |
---|
1047 | displayField: "name", |
---|
1048 | fieldLabel: "Layout", |
---|
1049 | typeAhead: true, |
---|
1050 | mode: "local", |
---|
1051 | triggerAction: "all", |
---|
1052 | plugins: new GeoExt.plugins.PrintProviderField({ |
---|
1053 | printProvider: printProvider |
---|
1054 | }) |
---|
1055 | }, { |
---|
1056 | xtype: "combo", |
---|
1057 | store: printProvider.dpis, |
---|
1058 | displayField: "name", |
---|
1059 | fieldLabel: "Resolution", |
---|
1060 | tpl: '<tpl for="."><div class="x-combo-list-item">{name} dpi</div></tpl>', |
---|
1061 | typeAhead: true, |
---|
1062 | mode: "local", |
---|
1063 | triggerAction: "all", |
---|
1064 | plugins: new GeoExt.plugins.PrintProviderField({ |
---|
1065 | printProvider: printProvider |
---|
1066 | }), |
---|
1067 | // the plugin will work even if we modify a combo value |
---|
1068 | setValue: function(v) { |
---|
1069 | v = parseInt(v) + " dpi"; |
---|
1070 | Ext.form.ComboBox.prototype.setValue.apply(this, arguments); |
---|
1071 | } |
---|
1072 | }, { |
---|
1073 | xtype: "combo", |
---|
1074 | store: printProvider.scales, |
---|
1075 | displayField: "name", |
---|
1076 | fieldLabel: "Scale", |
---|
1077 | typeAhead: true, |
---|
1078 | mode: "local", |
---|
1079 | triggerAction: "all", |
---|
1080 | plugins: new GeoExt.plugins.PrintPageField({ |
---|
1081 | printPage: printPage |
---|
1082 | }) |
---|
1083 | }, { |
---|
1084 | xtype: "textfield", |
---|
1085 | name: "rotation", |
---|
1086 | fieldLabel: "Rotation", |
---|
1087 | plugins: new GeoExt.plugins.PrintPageField({ |
---|
1088 | printPage: printPage |
---|
1089 | }) |
---|
1090 | }], |
---|
1091 | buttons: [{ |
---|
1092 | text: "Create PDF", |
---|
1093 | handler: function() { |
---|
1094 | printProvider.print(mapPanel, printPage); |
---|
1095 | } |
---|
1096 | }] |
---|
1097 | }); |
---|
1098 | |
---|
1099 | // The main panel |
---|
1100 | new Ext.Panel({ |
---|
1101 | renderTo: "content", |
---|
1102 | layout: "border", |
---|
1103 | width: 700, |
---|
1104 | height: 420, |
---|
1105 | items: [mapPanel, formPanel] |
---|
1106 | }); |
---|
1107 | }); |
---|
1108 | /** |
---|
1109 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1110 | * |
---|
1111 | * Published under the BSD license. |
---|
1112 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1113 | * of the license. |
---|
1114 | */ |
---|
1115 | |
---|
1116 | /** api: example[print-page] |
---|
1117 | * Print Your Map |
---|
1118 | * -------------- |
---|
1119 | * Print the visible extent of a MapPanel with PrintPage and PrintProvider. |
---|
1120 | */ |
---|
1121 | |
---|
1122 | var mapPanel, printPage; |
---|
1123 | |
---|
1124 | Ext.onReady(function() { |
---|
1125 | // The printProvider that connects us to the print service |
---|
1126 | var printProvider = new GeoExt.data.PrintProvider({ |
---|
1127 | method: "GET", // "POST" recommended for production use |
---|
1128 | capabilities: printCapabilities // from the info.json script in the html |
---|
1129 | }); |
---|
1130 | // Our print page. Tells the PrintProvider about the scale and center of |
---|
1131 | // our page. |
---|
1132 | printPage = new GeoExt.data.PrintPage({ |
---|
1133 | printProvider: printProvider, |
---|
1134 | customParams: { |
---|
1135 | mapTitle: "Printing Demo", |
---|
1136 | comment: "This is a simple map printed from GeoExt." |
---|
1137 | } |
---|
1138 | }); |
---|
1139 | |
---|
1140 | // The map we want to print |
---|
1141 | mapPanel = new GeoExt.MapPanel({ |
---|
1142 | region: "center", |
---|
1143 | layers: [new OpenLayers.Layer.WMS("Tasmania", "http://demo.opengeo.org/geoserver/wms", |
---|
1144 | {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})], |
---|
1145 | center: [146.56, -41.56], |
---|
1146 | zoom: 7 |
---|
1147 | }); |
---|
1148 | // The legend to optionally include on the printout |
---|
1149 | var legendPanel = new GeoExt.LegendPanel({ |
---|
1150 | region: "west", |
---|
1151 | width: 150, |
---|
1152 | bodyStyle: "padding:5px", |
---|
1153 | layerStore: mapPanel.layers |
---|
1154 | }); |
---|
1155 | |
---|
1156 | var includeLegend; // controlled by the "Include legend?" checkbox |
---|
1157 | |
---|
1158 | // The main panel |
---|
1159 | new Ext.Panel({ |
---|
1160 | renderTo: "content", |
---|
1161 | layout: "border", |
---|
1162 | width: 700, |
---|
1163 | height: 420, |
---|
1164 | items: [mapPanel, legendPanel], |
---|
1165 | bbar: ["->", { |
---|
1166 | text: "Print", |
---|
1167 | handler: function() { |
---|
1168 | // convenient way to fit the print page to the visible map area |
---|
1169 | printPage.fit(mapPanel, true); |
---|
1170 | // print the page, optionally including the legend |
---|
1171 | printProvider.print(mapPanel, printPage, includeLegend && {legend: legendPanel}); |
---|
1172 | } |
---|
1173 | }, { |
---|
1174 | xtype: "checkbox", |
---|
1175 | boxLabel: "Include legend?", |
---|
1176 | handler: function() {includeLegend = this.checked} |
---|
1177 | }] |
---|
1178 | }); |
---|
1179 | }); |
---|
1180 | /** |
---|
1181 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1182 | * |
---|
1183 | * Published under the BSD license. |
---|
1184 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1185 | * of the license. |
---|
1186 | */ |
---|
1187 | |
---|
1188 | /** api: example[print-preview-osm] |
---|
1189 | * Printing OpenStreetMap |
---|
1190 | * ---------------------------------------- |
---|
1191 | * PrintMapPanel with an OSM map. |
---|
1192 | */ |
---|
1193 | |
---|
1194 | var mapPanel, printDialog; |
---|
1195 | |
---|
1196 | Ext.onReady(function() { |
---|
1197 | // The PrintProvider that connects us to the print service |
---|
1198 | var printProvider = new GeoExt.data.PrintProvider({ |
---|
1199 | method: "GET", // "POST" recommended for production use |
---|
1200 | capabilities: printCapabilities, // provide url instead for lazy loading |
---|
1201 | customParams: { |
---|
1202 | mapTitle: "GeoExt Printing Demo", |
---|
1203 | comment: "This demo shows how to use GeoExt.PrintMapPanel with OSM" |
---|
1204 | } |
---|
1205 | }); |
---|
1206 | |
---|
1207 | // A MapPanel with a "Print..." button |
---|
1208 | mapPanel = new GeoExt.MapPanel({ |
---|
1209 | renderTo: "content", |
---|
1210 | width: 500, |
---|
1211 | height: 350, |
---|
1212 | map: { |
---|
1213 | maxExtent: new OpenLayers.Bounds( |
---|
1214 | -128 * 156543.0339, |
---|
1215 | -128 * 156543.0339, |
---|
1216 | 128 * 156543.0339, |
---|
1217 | 128 * 156543.0339 |
---|
1218 | ), |
---|
1219 | maxResolution: 156543.0339, |
---|
1220 | units: "m", |
---|
1221 | projection: "EPSG:900913" |
---|
1222 | }, |
---|
1223 | layers: [new OpenLayers.Layer.OSM()], |
---|
1224 | /*layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries", |
---|
1225 | "http://demo.opengeo.org/geoserver/wms", |
---|
1226 | {layers: "topp:tasmania_state_boundaries"}, {singleTile: true})],*/ |
---|
1227 | center: [16314984.568391, -5095295.7603428], |
---|
1228 | zoom: 6, |
---|
1229 | bbar: [{ |
---|
1230 | text: "Print...", |
---|
1231 | handler: function(){ |
---|
1232 | // A window with the PrintMapPanel, which we can use to adjust |
---|
1233 | // the print extent before creating the pdf. |
---|
1234 | printDialog = new Ext.Window({ |
---|
1235 | title: "Print Preview", |
---|
1236 | width: 350, |
---|
1237 | autoHeight: true, |
---|
1238 | items: [{ |
---|
1239 | xtype: "gx_printmappanel", |
---|
1240 | // use only a PanPanel control |
---|
1241 | map: {controls: [new OpenLayers.Control.PanPanel()]}, |
---|
1242 | sourceMap: mapPanel, |
---|
1243 | printProvider: printProvider |
---|
1244 | }], |
---|
1245 | bbar: [{ |
---|
1246 | text: "Create PDF", |
---|
1247 | handler: function(){ printDialog.items.get(0).print(); } |
---|
1248 | }] |
---|
1249 | }); |
---|
1250 | printDialog.show(); |
---|
1251 | } |
---|
1252 | }] |
---|
1253 | }); |
---|
1254 | |
---|
1255 | }); /** |
---|
1256 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1257 | * |
---|
1258 | * Published under the BSD license. |
---|
1259 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1260 | * of the license. |
---|
1261 | */ |
---|
1262 | |
---|
1263 | /** api: example[print-preview] |
---|
1264 | * Print Preview Window |
---|
1265 | * -------------------- |
---|
1266 | * Use the PrintMapPanel for interactive print previews. |
---|
1267 | */ |
---|
1268 | |
---|
1269 | var mapPanel, printDialog; |
---|
1270 | |
---|
1271 | Ext.onReady(function() { |
---|
1272 | // The PrintProvider that connects us to the print service |
---|
1273 | var printProvider = new GeoExt.data.PrintProvider({ |
---|
1274 | method: "GET", // "POST" recommended for production use |
---|
1275 | capabilities: printCapabilities, // provide url instead for lazy loading |
---|
1276 | customParams: { |
---|
1277 | mapTitle: "GeoExt Printing Demo", |
---|
1278 | comment: "This demo shows how to use GeoExt.PrintMapPanel" |
---|
1279 | } |
---|
1280 | }); |
---|
1281 | |
---|
1282 | // A MapPanel with a "Print..." button |
---|
1283 | mapPanel = new GeoExt.MapPanel({ |
---|
1284 | renderTo: "content", |
---|
1285 | width: 500, |
---|
1286 | height: 350, |
---|
1287 | map: { |
---|
1288 | maxExtent: new OpenLayers.Bounds( |
---|
1289 | 143.835, -43.648, |
---|
1290 | 148.479, -39.574 |
---|
1291 | ), |
---|
1292 | maxResolution: 0.018140625, |
---|
1293 | projection: "EPSG:4326", |
---|
1294 | units: 'degrees' |
---|
1295 | }, |
---|
1296 | layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries", |
---|
1297 | "http://demo.opengeo.org/geoserver/wms", |
---|
1298 | {layers: "topp:tasmania_state_boundaries"}, |
---|
1299 | {singleTile: true, numZoomLevels: 8})], |
---|
1300 | center: [146.56, -41.56], |
---|
1301 | zoom: 0, |
---|
1302 | bbar: [{ |
---|
1303 | text: "Print...", |
---|
1304 | handler: function(){ |
---|
1305 | // A window with the PrintMapPanel, which we can use to adjust |
---|
1306 | // the print extent before creating the pdf. |
---|
1307 | printDialog = new Ext.Window({ |
---|
1308 | title: "Print Preview", |
---|
1309 | layout: "fit", |
---|
1310 | width: 350, |
---|
1311 | autoHeight: true, |
---|
1312 | items: [{ |
---|
1313 | xtype: "gx_printmappanel", |
---|
1314 | sourceMap: mapPanel, |
---|
1315 | printProvider: printProvider |
---|
1316 | }], |
---|
1317 | bbar: [{ |
---|
1318 | text: "Create PDF", |
---|
1319 | handler: function(){ printDialog.items.get(0).print(); } |
---|
1320 | }] |
---|
1321 | }); |
---|
1322 | printDialog.show(); |
---|
1323 | } |
---|
1324 | }] |
---|
1325 | }); |
---|
1326 | |
---|
1327 | });/** |
---|
1328 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1329 | * |
---|
1330 | * Published under the BSD license. |
---|
1331 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1332 | * of the license. |
---|
1333 | */ |
---|
1334 | |
---|
1335 | /** api: example[renderer] |
---|
1336 | * Feature Renderer |
---|
1337 | * ---------------- |
---|
1338 | * Render a vector feature with multiple symbolizers in a box component. |
---|
1339 | */ |
---|
1340 | |
---|
1341 | var blue = { |
---|
1342 | fillColor: "blue", |
---|
1343 | fillOpacity: 0.25, |
---|
1344 | strokeColor: "blue", |
---|
1345 | strokeWidth: 2, |
---|
1346 | pointRadius: 5 |
---|
1347 | }; |
---|
1348 | |
---|
1349 | var custom = { |
---|
1350 | point: { |
---|
1351 | graphicName: "star", |
---|
1352 | pointRadius: 8, |
---|
1353 | fillColor: "yellow", |
---|
1354 | strokeColor: "red", |
---|
1355 | strokeWidth: 1 |
---|
1356 | }, |
---|
1357 | line: { |
---|
1358 | strokeColor: "#669900", |
---|
1359 | strokeWidth: 3 |
---|
1360 | }, |
---|
1361 | poly: { |
---|
1362 | fillColor: "olive", |
---|
1363 | fillOpacity: 0.25, |
---|
1364 | strokeColor: "#666666", |
---|
1365 | strokeWidth: 2, |
---|
1366 | strokeDashstyle: "dot" |
---|
1367 | } |
---|
1368 | }; |
---|
1369 | |
---|
1370 | var stacked = { |
---|
1371 | point: [{ |
---|
1372 | pointRadius: 8, |
---|
1373 | fillColor: "white", |
---|
1374 | strokeColor: "red", |
---|
1375 | strokeWidth: 2 |
---|
1376 | }, { |
---|
1377 | graphicName: "star", |
---|
1378 | pointRadius: 5, |
---|
1379 | fillColor: "red" |
---|
1380 | }], |
---|
1381 | line: [{ |
---|
1382 | strokeColor: "red", |
---|
1383 | strokeWidth: 5 |
---|
1384 | }, { |
---|
1385 | strokeColor: "#ff9933", |
---|
1386 | strokeWidth: 2 |
---|
1387 | }], |
---|
1388 | poly: [{ |
---|
1389 | strokeWidth: 3, |
---|
1390 | fillColor: "white", |
---|
1391 | strokeColor: "#669900" |
---|
1392 | }, { |
---|
1393 | strokeWidth: 2, |
---|
1394 | fillOpacity: 0, |
---|
1395 | strokeColor: "red", |
---|
1396 | strokeDashstyle: "dot" |
---|
1397 | }] |
---|
1398 | }; |
---|
1399 | |
---|
1400 | var configs = [{ |
---|
1401 | symbolType: "Point", |
---|
1402 | renderTo: "point_default" |
---|
1403 | }, { |
---|
1404 | symbolType: "Line", |
---|
1405 | renderTo: "line_default" |
---|
1406 | }, { |
---|
1407 | symbolType: "Polygon", |
---|
1408 | renderTo: "poly_default" |
---|
1409 | }, { |
---|
1410 | symbolType: "Point", |
---|
1411 | symbolizers: [blue], |
---|
1412 | renderTo: "point_blue" |
---|
1413 | }, { |
---|
1414 | symbolType: "Line", |
---|
1415 | symbolizers: [blue], |
---|
1416 | renderTo: "line_blue" |
---|
1417 | }, { |
---|
1418 | symbolType: "Polygon", |
---|
1419 | symbolizers: [blue], |
---|
1420 | renderTo: "poly_blue" |
---|
1421 | }, { |
---|
1422 | symbolType: "Point", |
---|
1423 | symbolizers: [custom.point], |
---|
1424 | renderTo: "point_custom" |
---|
1425 | }, { |
---|
1426 | symbolType: "Line", |
---|
1427 | symbolizers: [custom.line], |
---|
1428 | renderTo: "line_custom" |
---|
1429 | }, { |
---|
1430 | symbolType: "Polygon", |
---|
1431 | symbolizers: [custom.poly], |
---|
1432 | renderTo: "poly_custom" |
---|
1433 | }, { |
---|
1434 | symbolType: "Point", |
---|
1435 | symbolizers: stacked.point, |
---|
1436 | renderTo: "point_stacked" |
---|
1437 | }, { |
---|
1438 | symbolType: "Line", |
---|
1439 | symbolizers: stacked.line, |
---|
1440 | renderTo: "line_stacked" |
---|
1441 | }, { |
---|
1442 | symbolType: "Polygon", |
---|
1443 | symbolizers: stacked.poly, |
---|
1444 | renderTo: "poly_stacked" |
---|
1445 | }]; |
---|
1446 | |
---|
1447 | Ext.onReady(function() { |
---|
1448 | for(var i=0; i<configs.length; ++i) { |
---|
1449 | new GeoExt.FeatureRenderer(configs[i]); |
---|
1450 | } |
---|
1451 | $("render").onclick = render; |
---|
1452 | }); |
---|
1453 | |
---|
1454 | var format = new OpenLayers.Format.WKT(); |
---|
1455 | var renderer, win; |
---|
1456 | function render() { |
---|
1457 | var wkt = $("wkt").value; |
---|
1458 | var feature; |
---|
1459 | try { |
---|
1460 | feature = format.read(wkt) |
---|
1461 | } catch(err) { |
---|
1462 | $("wkt").value = "Bad WKT: " + err; |
---|
1463 | } |
---|
1464 | var symbolizers; |
---|
1465 | try { |
---|
1466 | var value = $("symbolizers").value; |
---|
1467 | symbolizers = eval("(" + value + ")"); |
---|
1468 | if (!symbolizers || symbolizers.constructor !== Array) { |
---|
1469 | throw "Must be an array literal"; |
---|
1470 | } |
---|
1471 | } catch(err) { |
---|
1472 | $("symbolizers").value = "Bad symbolizers: " + err + "\n\n" + value; |
---|
1473 | symbolizers = null; |
---|
1474 | } |
---|
1475 | if(feature && symbolizers) { |
---|
1476 | if(!win) { |
---|
1477 | renderer = new GeoExt.FeatureRenderer({ |
---|
1478 | feature: feature, |
---|
1479 | symbolizers: symbolizers, |
---|
1480 | width: 150, |
---|
1481 | style: {margin: 4} |
---|
1482 | }); |
---|
1483 | win = new Ext.Window({ |
---|
1484 | closeAction: "hide", |
---|
1485 | layout: "fit", |
---|
1486 | width: 175, |
---|
1487 | items: [renderer] |
---|
1488 | }); |
---|
1489 | } else { |
---|
1490 | renderer.update({ |
---|
1491 | feature: feature, |
---|
1492 | symbolizers: symbolizers |
---|
1493 | }); |
---|
1494 | } |
---|
1495 | win.show(); |
---|
1496 | } |
---|
1497 | } |
---|
1498 | |
---|
1499 | /** |
---|
1500 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1501 | * |
---|
1502 | * Published under the BSD license. |
---|
1503 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1504 | * of the license. |
---|
1505 | */ |
---|
1506 | |
---|
1507 | /** api: example[search-form] |
---|
1508 | * Filter Form Panel |
---|
1509 | * ----------------- |
---|
1510 | * Use a form to build an OpenLayers filter. |
---|
1511 | */ |
---|
1512 | |
---|
1513 | var formPanel; |
---|
1514 | |
---|
1515 | Ext.onReady(function() { |
---|
1516 | |
---|
1517 | // create a protocol, this protocol is used by the form |
---|
1518 | // to send the search request, this protocol's read |
---|
1519 | // method received an OpenLayers.Filter instance, |
---|
1520 | // which is derived from the content of the form |
---|
1521 | var protocol = new OpenLayers.Protocol({ |
---|
1522 | read: function(options) { |
---|
1523 | var f; html = []; |
---|
1524 | |
---|
1525 | f = options.filter; |
---|
1526 | html.push([f.CLASS_NAME, ",", f.type, "<br />"].join(" ")); |
---|
1527 | |
---|
1528 | f = options.filter.filters[0]; |
---|
1529 | html.push([f.CLASS_NAME, ",", f.type, ",", |
---|
1530 | f.property, ":", f.value, "<br />"].join(" ")); |
---|
1531 | |
---|
1532 | f = options.filter.filters[1]; |
---|
1533 | html.push([f.CLASS_NAME, ",", f.type, ", ", |
---|
1534 | f.property, ": ", f.value].join(" ")); |
---|
1535 | |
---|
1536 | Ext.get("filter").update(html.join("")); |
---|
1537 | |
---|
1538 | } |
---|
1539 | }); |
---|
1540 | |
---|
1541 | // create a GeoExt form panel (configured with an OpenLayers.Protocol |
---|
1542 | // instance) |
---|
1543 | formPanel = new GeoExt.form.FormPanel({ |
---|
1544 | width: 300, |
---|
1545 | height: 200, |
---|
1546 | protocol: protocol, |
---|
1547 | items: [{ |
---|
1548 | xtype: "textfield", |
---|
1549 | name: "name__like", |
---|
1550 | value: "foo", |
---|
1551 | fieldLabel: "name" |
---|
1552 | }, { |
---|
1553 | xtype: "textfield", |
---|
1554 | name: "elevation__ge", |
---|
1555 | value: "1200", |
---|
1556 | fieldLabel: "maximum elevation" |
---|
1557 | }], |
---|
1558 | listeners: { |
---|
1559 | actioncomplete: function(form, action) { |
---|
1560 | // this listener triggers when the search request |
---|
1561 | // is complete, the OpenLayers.Protocol.Response |
---|
1562 | // resulting from the request is available |
---|
1563 | // through "action.response" |
---|
1564 | } |
---|
1565 | } |
---|
1566 | }); |
---|
1567 | |
---|
1568 | formPanel.addButton({ |
---|
1569 | text: "search", |
---|
1570 | handler: function() { |
---|
1571 | // trigger search request, the options passed to doAction |
---|
1572 | // are passed to the protocol's read method, so one |
---|
1573 | // can register a read callback here |
---|
1574 | var o = { |
---|
1575 | callback: function(response) { |
---|
1576 | } |
---|
1577 | }; |
---|
1578 | this.search(o); |
---|
1579 | }, |
---|
1580 | scope: formPanel |
---|
1581 | }); |
---|
1582 | |
---|
1583 | formPanel.render("formpanel"); |
---|
1584 | }); |
---|
1585 | /** |
---|
1586 | * Copyright (c) 2008-2009 The Open Source Geospatial Foundation |
---|
1587 | * |
---|
1588 | * Published under the BSD license. |
---|
1589 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1590 | * of the license. |
---|
1591 | */ |
---|
1592 | |
---|
1593 | Ext.onReady(function(){ |
---|
1594 | |
---|
1595 | new Ext.Slider({ |
---|
1596 | renderTo: "tip-slider", |
---|
1597 | width: 214, |
---|
1598 | minValue: 0, |
---|
1599 | maxValue: 100, |
---|
1600 | plugins: new GeoExt.SliderTip() |
---|
1601 | }); |
---|
1602 | |
---|
1603 | new Ext.Slider({ |
---|
1604 | renderTo: "custom-tip-slider", |
---|
1605 | width: 214, |
---|
1606 | increment: 10, |
---|
1607 | minValue: 0, |
---|
1608 | maxValue: 100, |
---|
1609 | plugins: new GeoExt.SliderTip({ |
---|
1610 | getText: function(thumb){ |
---|
1611 | return String.format("<b>{0}% complete</b>", thumb.value); |
---|
1612 | } |
---|
1613 | }) |
---|
1614 | }); |
---|
1615 | |
---|
1616 | new Ext.Slider({ |
---|
1617 | renderTo: "no-hover-tip", |
---|
1618 | width: 214, |
---|
1619 | increment: 10, |
---|
1620 | minValue: 0, |
---|
1621 | maxValue: 100, |
---|
1622 | plugins: new GeoExt.SliderTip({hover: false}) |
---|
1623 | }); |
---|
1624 | |
---|
1625 | new Ext.Slider({ |
---|
1626 | renderTo: "multi-slider-horizontal", |
---|
1627 | width : 214, |
---|
1628 | minValue: 0, |
---|
1629 | maxValue: 100, |
---|
1630 | values : [10, 50, 90], |
---|
1631 | plugins : new GeoExt.SliderTip() |
---|
1632 | }); |
---|
1633 | |
---|
1634 | new Ext.Slider({ |
---|
1635 | renderTo : "multi-slider-vertical", |
---|
1636 | vertical : true, |
---|
1637 | height : 214, |
---|
1638 | minValue: 0, |
---|
1639 | maxValue: 100, |
---|
1640 | values : [10, 50, 90], |
---|
1641 | plugins : new GeoExt.SliderTip() |
---|
1642 | }); |
---|
1643 | }); |
---|
1644 | /** |
---|
1645 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1646 | * |
---|
1647 | * Published under the BSD license. |
---|
1648 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1649 | * of the license. |
---|
1650 | */ |
---|
1651 | |
---|
1652 | /** api: example[toolbar] |
---|
1653 | * Toolbar with Actions |
---|
1654 | * -------------------- |
---|
1655 | * Create a toolbar with GeoExt Actions. |
---|
1656 | */ |
---|
1657 | |
---|
1658 | Ext.onReady(function() { |
---|
1659 | Ext.QuickTips.init(); |
---|
1660 | |
---|
1661 | var map = new OpenLayers.Map(); |
---|
1662 | var wms = new OpenLayers.Layer.WMS( |
---|
1663 | "Global Imagery", |
---|
1664 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
1665 | {layers: "bluemarble"} |
---|
1666 | ); |
---|
1667 | var vector = new OpenLayers.Layer.Vector("vector"); |
---|
1668 | map.addLayers([wms, vector]); |
---|
1669 | |
---|
1670 | var ctrl, toolbarItems = [], action, actions = {}; |
---|
1671 | |
---|
1672 | // ZoomToMaxExtent control, a "button" control |
---|
1673 | action = new GeoExt.Action({ |
---|
1674 | control: new OpenLayers.Control.ZoomToMaxExtent(), |
---|
1675 | map: map, |
---|
1676 | text: "max extent", |
---|
1677 | tooltip: "zoom to max extent" |
---|
1678 | }); |
---|
1679 | actions["max_extent"] = action; |
---|
1680 | toolbarItems.push(action); |
---|
1681 | toolbarItems.push("-"); |
---|
1682 | |
---|
1683 | // Navigation control and DrawFeature controls |
---|
1684 | // in the same toggle group |
---|
1685 | action = new GeoExt.Action({ |
---|
1686 | text: "nav", |
---|
1687 | control: new OpenLayers.Control.Navigation(), |
---|
1688 | map: map, |
---|
1689 | // button options |
---|
1690 | toggleGroup: "draw", |
---|
1691 | allowDepress: false, |
---|
1692 | pressed: true, |
---|
1693 | tooltip: "navigate", |
---|
1694 | // check item options |
---|
1695 | group: "draw", |
---|
1696 | checked: true |
---|
1697 | }); |
---|
1698 | actions["nav"] = action; |
---|
1699 | toolbarItems.push(action); |
---|
1700 | |
---|
1701 | action = new GeoExt.Action({ |
---|
1702 | text: "draw poly", |
---|
1703 | control: new OpenLayers.Control.DrawFeature( |
---|
1704 | vector, OpenLayers.Handler.Polygon |
---|
1705 | ), |
---|
1706 | map: map, |
---|
1707 | // button options |
---|
1708 | toggleGroup: "draw", |
---|
1709 | allowDepress: false, |
---|
1710 | tooltip: "draw polygon", |
---|
1711 | // check item options |
---|
1712 | group: "draw" |
---|
1713 | }); |
---|
1714 | actions["draw_poly"] = action; |
---|
1715 | toolbarItems.push(action); |
---|
1716 | |
---|
1717 | action = new GeoExt.Action({ |
---|
1718 | text: "draw line", |
---|
1719 | control: new OpenLayers.Control.DrawFeature( |
---|
1720 | vector, OpenLayers.Handler.Path |
---|
1721 | ), |
---|
1722 | map: map, |
---|
1723 | // button options |
---|
1724 | toggleGroup: "draw", |
---|
1725 | allowDepress: false, |
---|
1726 | tooltip: "draw line", |
---|
1727 | // check item options |
---|
1728 | group: "draw" |
---|
1729 | }); |
---|
1730 | actions["draw_line"] = action; |
---|
1731 | toolbarItems.push(action); |
---|
1732 | toolbarItems.push("-"); |
---|
1733 | |
---|
1734 | // SelectFeature control, a "toggle" control |
---|
1735 | action = new GeoExt.Action({ |
---|
1736 | text: "select", |
---|
1737 | control: new OpenLayers.Control.SelectFeature(vector, { |
---|
1738 | type: OpenLayers.Control.TYPE_TOGGLE, |
---|
1739 | hover: true |
---|
1740 | }), |
---|
1741 | map: map, |
---|
1742 | // button options |
---|
1743 | enableToggle: true, |
---|
1744 | tooltip: "select feature" |
---|
1745 | }); |
---|
1746 | actions["select"] = action; |
---|
1747 | toolbarItems.push(action); |
---|
1748 | toolbarItems.push("-"); |
---|
1749 | |
---|
1750 | // Navigation history - two "button" controls |
---|
1751 | ctrl = new OpenLayers.Control.NavigationHistory(); |
---|
1752 | map.addControl(ctrl); |
---|
1753 | |
---|
1754 | action = new GeoExt.Action({ |
---|
1755 | text: "previous", |
---|
1756 | control: ctrl.previous, |
---|
1757 | disabled: true, |
---|
1758 | tooltip: "previous in history" |
---|
1759 | }); |
---|
1760 | actions["previous"] = action; |
---|
1761 | toolbarItems.push(action); |
---|
1762 | |
---|
1763 | action = new GeoExt.Action({ |
---|
1764 | text: "next", |
---|
1765 | control: ctrl.next, |
---|
1766 | disabled: true, |
---|
1767 | tooltip: "next in history" |
---|
1768 | }); |
---|
1769 | actions["next"] = action; |
---|
1770 | toolbarItems.push(action); |
---|
1771 | toolbarItems.push("->"); |
---|
1772 | |
---|
1773 | // Reuse the GeoExt.Action objects created above |
---|
1774 | // as menu items |
---|
1775 | toolbarItems.push({ |
---|
1776 | text: "menu", |
---|
1777 | menu: new Ext.menu.Menu({ |
---|
1778 | items: [ |
---|
1779 | // ZoomToMaxExtent |
---|
1780 | actions["max_extent"], |
---|
1781 | // Nav |
---|
1782 | new Ext.menu.CheckItem(actions["nav"]), |
---|
1783 | // Draw poly |
---|
1784 | new Ext.menu.CheckItem(actions["draw_poly"]), |
---|
1785 | // Draw line |
---|
1786 | new Ext.menu.CheckItem(actions["draw_line"]), |
---|
1787 | // Select control |
---|
1788 | new Ext.menu.CheckItem(actions["select"]), |
---|
1789 | // Navigation history control |
---|
1790 | actions["previous"], |
---|
1791 | actions["next"] |
---|
1792 | ] |
---|
1793 | }) |
---|
1794 | }); |
---|
1795 | |
---|
1796 | var mapPanel = new GeoExt.MapPanel({ |
---|
1797 | renderTo: "mappanel", |
---|
1798 | height: 400, |
---|
1799 | width: 600, |
---|
1800 | map: map, |
---|
1801 | center: new OpenLayers.LonLat(5, 45), |
---|
1802 | zoom: 4, |
---|
1803 | tbar: toolbarItems |
---|
1804 | }); |
---|
1805 | }); |
---|
1806 | /** |
---|
1807 | * Copyright (c) 2008-2009 The Open Source Geospatial Foundation |
---|
1808 | * |
---|
1809 | * Published under the BSD license. |
---|
1810 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1811 | * of the license. |
---|
1812 | */ |
---|
1813 | |
---|
1814 | /** api: example[tree-legend] |
---|
1815 | * Tree Legend |
---|
1816 | * ----------- |
---|
1817 | * Render layer nodes with legends. |
---|
1818 | */ |
---|
1819 | |
---|
1820 | // custom layer node UI class |
---|
1821 | var LayerNodeUI = Ext.extend( |
---|
1822 | GeoExt.tree.LayerNodeUI, |
---|
1823 | new GeoExt.tree.TreeNodeUIEventMixin() |
---|
1824 | ); |
---|
1825 | |
---|
1826 | Ext.onReady(function() { |
---|
1827 | var mapPanel = new GeoExt.MapPanel({ |
---|
1828 | region: "center", |
---|
1829 | center: [146.1569825, -41.6109735], |
---|
1830 | zoom: 6, |
---|
1831 | layers: [ |
---|
1832 | new OpenLayers.Layer.WMS("Tasmania State Boundaries", |
---|
1833 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1834 | layers: "topp:tasmania_state_boundaries" |
---|
1835 | }, { |
---|
1836 | buffer: 0, |
---|
1837 | // exclude this layer from layer container nodes |
---|
1838 | displayInLayerSwitcher: false |
---|
1839 | }), |
---|
1840 | new OpenLayers.Layer.WMS("Water", |
---|
1841 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1842 | layers: "topp:tasmania_water_bodies", |
---|
1843 | transparent: true, |
---|
1844 | format: "image/gif" |
---|
1845 | }, { |
---|
1846 | buffer: 0 |
---|
1847 | }), |
---|
1848 | new OpenLayers.Layer.WMS("Cities", |
---|
1849 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1850 | layers: "topp:tasmania_cities", |
---|
1851 | transparent: true, |
---|
1852 | format: "image/gif" |
---|
1853 | }, { |
---|
1854 | buffer: 0 |
---|
1855 | }), |
---|
1856 | new OpenLayers.Layer.WMS("Tasmania Roads", |
---|
1857 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1858 | layers: "topp:tasmania_roads", |
---|
1859 | transparent: true, |
---|
1860 | format: "image/gif" |
---|
1861 | }, { |
---|
1862 | buffer: 0 |
---|
1863 | }) |
---|
1864 | ] |
---|
1865 | }); |
---|
1866 | |
---|
1867 | var tree = new Ext.tree.TreePanel({ |
---|
1868 | region: "east", |
---|
1869 | title: "Layers", |
---|
1870 | width: 250, |
---|
1871 | autoScroll: true, |
---|
1872 | enableDD: true, |
---|
1873 | // apply the tree node component plugin to layer nodes |
---|
1874 | plugins: [{ |
---|
1875 | ptype: "gx_treenodecomponent" |
---|
1876 | }], |
---|
1877 | loader: { |
---|
1878 | applyLoader: false, |
---|
1879 | uiProviders: { |
---|
1880 | "custom_ui": LayerNodeUI |
---|
1881 | } |
---|
1882 | }, |
---|
1883 | root: { |
---|
1884 | nodeType: "gx_layercontainer", |
---|
1885 | loader: { |
---|
1886 | baseAttrs: { |
---|
1887 | uiProvider: "custom_ui" |
---|
1888 | }, |
---|
1889 | createNode: function(attr) { |
---|
1890 | // add a WMS legend to each node created |
---|
1891 | attr.component = { |
---|
1892 | xtype: "gx_wmslegend", |
---|
1893 | layerRecord: mapPanel.layers.getByLayer(attr.layer), |
---|
1894 | showTitle: false, |
---|
1895 | // custom class for css positioning |
---|
1896 | // see tree-legend.html |
---|
1897 | cls: "legend" |
---|
1898 | } |
---|
1899 | return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr); |
---|
1900 | } |
---|
1901 | } |
---|
1902 | }, |
---|
1903 | rootVisible: false, |
---|
1904 | lines: false |
---|
1905 | }); |
---|
1906 | |
---|
1907 | new Ext.Viewport({ |
---|
1908 | layout: "fit", |
---|
1909 | hideBorders: true, |
---|
1910 | items: { |
---|
1911 | layout: "border", |
---|
1912 | items: [ |
---|
1913 | mapPanel, tree, { |
---|
1914 | contentEl: desc, |
---|
1915 | region: "west", |
---|
1916 | width: 250, |
---|
1917 | bodyStyle: {padding: "5px"} |
---|
1918 | } |
---|
1919 | ] |
---|
1920 | } |
---|
1921 | }); |
---|
1922 | }); |
---|
1923 | /** |
---|
1924 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
1925 | * |
---|
1926 | * Published under the BSD license. |
---|
1927 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
1928 | * of the license. |
---|
1929 | */ |
---|
1930 | |
---|
1931 | /** api: example[tree] |
---|
1932 | * Tree Nodes |
---|
1933 | * ---------- |
---|
1934 | * Create all kinds of tree nodes. |
---|
1935 | */ |
---|
1936 | |
---|
1937 | var mapPanel, tree; |
---|
1938 | Ext.onReady(function() { |
---|
1939 | // create a map panel with some layers that we will show in our layer tree |
---|
1940 | // below. |
---|
1941 | mapPanel = new GeoExt.MapPanel({ |
---|
1942 | border: true, |
---|
1943 | region: "center", |
---|
1944 | // we do not want all overlays, to try the OverlayLayerContainer |
---|
1945 | map: new OpenLayers.Map({allOverlays: false}), |
---|
1946 | center: [146.1569825, -41.6109735], |
---|
1947 | zoom: 6, |
---|
1948 | layers: [ |
---|
1949 | new OpenLayers.Layer.WMS("Global Imagery", |
---|
1950 | "http://maps.opengeo.org/geowebcache/service/wms", { |
---|
1951 | layers: "bluemarble" |
---|
1952 | }, { |
---|
1953 | buffer: 0, |
---|
1954 | visibility: false |
---|
1955 | } |
---|
1956 | ), |
---|
1957 | new OpenLayers.Layer.WMS("Tasmania State Boundaries", |
---|
1958 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1959 | layers: "topp:tasmania_state_boundaries" |
---|
1960 | }, { |
---|
1961 | buffer: 0 |
---|
1962 | } |
---|
1963 | ), |
---|
1964 | new OpenLayers.Layer.WMS("Water", |
---|
1965 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1966 | layers: "topp:tasmania_water_bodies", |
---|
1967 | transparent: true, |
---|
1968 | format: "image/gif" |
---|
1969 | }, { |
---|
1970 | isBaseLayer: false, |
---|
1971 | buffer: 0 |
---|
1972 | } |
---|
1973 | ), |
---|
1974 | new OpenLayers.Layer.WMS("Cities", |
---|
1975 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1976 | layers: "topp:tasmania_cities", |
---|
1977 | transparent: true, |
---|
1978 | format: "image/gif" |
---|
1979 | }, { |
---|
1980 | isBaseLayer: false, |
---|
1981 | buffer: 0 |
---|
1982 | } |
---|
1983 | ), |
---|
1984 | new OpenLayers.Layer.WMS("Tasmania Roads", |
---|
1985 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1986 | layers: "topp:tasmania_roads", |
---|
1987 | transparent: true, |
---|
1988 | format: "image/gif" |
---|
1989 | }, { |
---|
1990 | isBaseLayer: false, |
---|
1991 | buffer: 0 |
---|
1992 | } |
---|
1993 | ), |
---|
1994 | // create a group layer (with several layers in the "layers" param) |
---|
1995 | // to show how the LayerParamLoader works |
---|
1996 | new OpenLayers.Layer.WMS("Tasmania (Group Layer)", |
---|
1997 | "http://demo.opengeo.org/geoserver/wms", { |
---|
1998 | layers: [ |
---|
1999 | "topp:tasmania_state_boundaries", |
---|
2000 | "topp:tasmania_water_bodies", |
---|
2001 | "topp:tasmania_cities", |
---|
2002 | "topp:tasmania_roads" |
---|
2003 | ], |
---|
2004 | transparent: true, |
---|
2005 | format: "image/gif" |
---|
2006 | }, { |
---|
2007 | isBaseLayer: false, |
---|
2008 | buffer: 0, |
---|
2009 | // exclude this layer from layer container nodes |
---|
2010 | displayInLayerSwitcher: false, |
---|
2011 | visibility: false |
---|
2012 | } |
---|
2013 | ) |
---|
2014 | ] |
---|
2015 | }); |
---|
2016 | |
---|
2017 | // create our own layer node UI class, using the TreeNodeUIEventMixin |
---|
2018 | var LayerNodeUI = Ext.extend(GeoExt.tree.LayerNodeUI, new GeoExt.tree.TreeNodeUIEventMixin()); |
---|
2019 | |
---|
2020 | // using OpenLayers.Format.JSON to create a nice formatted string of the |
---|
2021 | // configuration for editing it in the UI |
---|
2022 | var treeConfig = new OpenLayers.Format.JSON().write([{ |
---|
2023 | nodeType: "gx_baselayercontainer" |
---|
2024 | }, { |
---|
2025 | nodeType: "gx_overlaylayercontainer", |
---|
2026 | expanded: true, |
---|
2027 | // render the nodes inside this container with a radio button, |
---|
2028 | // and assign them the group "foo". |
---|
2029 | loader: { |
---|
2030 | baseAttrs: { |
---|
2031 | radioGroup: "foo", |
---|
2032 | uiProvider: "layernodeui" |
---|
2033 | } |
---|
2034 | } |
---|
2035 | }, { |
---|
2036 | nodeType: "gx_layer", |
---|
2037 | layer: "Tasmania (Group Layer)", |
---|
2038 | isLeaf: false, |
---|
2039 | // create subnodes for the layers in the LAYERS param. If we assign |
---|
2040 | // a loader to a LayerNode and do not provide a loader class, a |
---|
2041 | // LayerParamLoader will be assumed. |
---|
2042 | loader: { |
---|
2043 | param: "LAYERS" |
---|
2044 | } |
---|
2045 | }], true); |
---|
2046 | |
---|
2047 | // create the tree with the configuration from above |
---|
2048 | tree = new Ext.tree.TreePanel({ |
---|
2049 | border: true, |
---|
2050 | region: "west", |
---|
2051 | title: "Layers", |
---|
2052 | width: 200, |
---|
2053 | split: true, |
---|
2054 | collapsible: true, |
---|
2055 | collapseMode: "mini", |
---|
2056 | autoScroll: true, |
---|
2057 | plugins: [ |
---|
2058 | new GeoExt.plugins.TreeNodeRadioButton({ |
---|
2059 | listeners: { |
---|
2060 | "radiochange": function(node) { |
---|
2061 | alert(node.text + " is now the active layer."); |
---|
2062 | } |
---|
2063 | } |
---|
2064 | }) |
---|
2065 | ], |
---|
2066 | loader: new Ext.tree.TreeLoader({ |
---|
2067 | // applyLoader has to be set to false to not interfer with loaders |
---|
2068 | // of nodes further down the tree hierarchy |
---|
2069 | applyLoader: false, |
---|
2070 | uiProviders: { |
---|
2071 | "layernodeui": LayerNodeUI |
---|
2072 | } |
---|
2073 | }), |
---|
2074 | root: { |
---|
2075 | nodeType: "async", |
---|
2076 | // the children property of an Ext.tree.AsyncTreeNode is used to |
---|
2077 | // provide an initial set of layer nodes. We use the treeConfig |
---|
2078 | // from above, that we created with OpenLayers.Format.JSON.write. |
---|
2079 | children: Ext.decode(treeConfig) |
---|
2080 | }, |
---|
2081 | listeners: { |
---|
2082 | "radiochange": function(node){ |
---|
2083 | alert(node.layer.name + " is now the the active layer."); |
---|
2084 | } |
---|
2085 | }, |
---|
2086 | rootVisible: false, |
---|
2087 | lines: false, |
---|
2088 | bbar: [{ |
---|
2089 | text: "Show/Edit Tree Config", |
---|
2090 | handler: function() { |
---|
2091 | treeConfigWin.show(); |
---|
2092 | Ext.getCmp("treeconfig").setValue(treeConfig); |
---|
2093 | } |
---|
2094 | }] |
---|
2095 | }); |
---|
2096 | |
---|
2097 | // dialog for editing the tree configuration |
---|
2098 | var treeConfigWin = new Ext.Window({ |
---|
2099 | layout: "fit", |
---|
2100 | hideBorders: true, |
---|
2101 | closeAction: "hide", |
---|
2102 | width: 300, |
---|
2103 | height: 400, |
---|
2104 | title: "Tree Configuration", |
---|
2105 | items: [{ |
---|
2106 | xtype: "form", |
---|
2107 | layout: "fit", |
---|
2108 | items: [{ |
---|
2109 | id: "treeconfig", |
---|
2110 | xtype: "textarea" |
---|
2111 | }], |
---|
2112 | buttons: [{ |
---|
2113 | text: "Save", |
---|
2114 | handler: function() { |
---|
2115 | var value = Ext.getCmp("treeconfig").getValue() |
---|
2116 | try { |
---|
2117 | var root = tree.getRootNode(); |
---|
2118 | root.attributes.children = Ext.decode(value); |
---|
2119 | tree.getLoader().load(root); |
---|
2120 | } catch(e) { |
---|
2121 | alert("Invalid JSON"); |
---|
2122 | return; |
---|
2123 | } |
---|
2124 | treeConfig = value; |
---|
2125 | treeConfigWin.hide(); |
---|
2126 | } |
---|
2127 | }, { |
---|
2128 | text: "Cancel", |
---|
2129 | handler: function() { |
---|
2130 | treeConfigWin.hide(); |
---|
2131 | } |
---|
2132 | }] |
---|
2133 | }] |
---|
2134 | }); |
---|
2135 | |
---|
2136 | new Ext.Viewport({ |
---|
2137 | layout: "fit", |
---|
2138 | hideBorders: true, |
---|
2139 | items: { |
---|
2140 | layout: "border", |
---|
2141 | deferredRender: false, |
---|
2142 | items: [mapPanel, tree, { |
---|
2143 | contentEl: "desc", |
---|
2144 | region: "east", |
---|
2145 | bodyStyle: {"padding": "5px"}, |
---|
2146 | collapsible: true, |
---|
2147 | collapseMode: "mini", |
---|
2148 | split: true, |
---|
2149 | width: 200, |
---|
2150 | title: "Description" |
---|
2151 | }] |
---|
2152 | } |
---|
2153 | }); |
---|
2154 | }); |
---|
2155 | /** |
---|
2156 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
2157 | * |
---|
2158 | * Published under the BSD license. |
---|
2159 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
2160 | * of the license. |
---|
2161 | */ |
---|
2162 | |
---|
2163 | /** api: example[vector-legend] |
---|
2164 | * Vector Legend |
---|
2165 | * ------------------------- |
---|
2166 | * Render a legend for a vector layer. |
---|
2167 | */ |
---|
2168 | |
---|
2169 | var mapPanel, legendPanel; |
---|
2170 | |
---|
2171 | Ext.onReady(function() { |
---|
2172 | |
---|
2173 | var rules = [ |
---|
2174 | new OpenLayers.Rule({ |
---|
2175 | title: "> 2000m", |
---|
2176 | maxScaleDenominator: 3000000, |
---|
2177 | filter: new OpenLayers.Filter.Comparison({ |
---|
2178 | type: OpenLayers.Filter.Comparison.GREATER_THAN, |
---|
2179 | property: "elevation", |
---|
2180 | value: 2000 |
---|
2181 | }), |
---|
2182 | symbolizer: { |
---|
2183 | graphicName: "star", |
---|
2184 | pointRadius: 8, |
---|
2185 | fillColor: "#99ccff", |
---|
2186 | strokeColor: "#666666", |
---|
2187 | strokeWidth: 1 |
---|
2188 | } |
---|
2189 | }), |
---|
2190 | new OpenLayers.Rule({ |
---|
2191 | title: "1500 - 2000m", |
---|
2192 | maxScaleDenominator: 3000000, |
---|
2193 | filter: new OpenLayers.Filter.Comparison({ |
---|
2194 | type: OpenLayers.Filter.Comparison.BETWEEN, |
---|
2195 | property: "elevation", |
---|
2196 | upperBoundary: 2000, |
---|
2197 | lowerBoundary: 1500 |
---|
2198 | }), |
---|
2199 | symbolizer: { |
---|
2200 | graphicName: "star", |
---|
2201 | pointRadius: 6, |
---|
2202 | fillColor: "#6699cc", |
---|
2203 | strokeColor: "#666666", |
---|
2204 | strokeWidth: 1 |
---|
2205 | } |
---|
2206 | }), |
---|
2207 | new OpenLayers.Rule({ |
---|
2208 | title: "< 1500m", |
---|
2209 | maxScaleDenominator: 3000000, |
---|
2210 | filter: new OpenLayers.Filter.Comparison({ |
---|
2211 | type: OpenLayers.Filter.Comparison.LESS_THAN, |
---|
2212 | property: "elevation", |
---|
2213 | value: 1500 |
---|
2214 | }), |
---|
2215 | symbolizer: { |
---|
2216 | graphicName: "star", |
---|
2217 | pointRadius: 4, |
---|
2218 | fillColor: "#0033cc", |
---|
2219 | strokeColor: "#666666", |
---|
2220 | strokeWidth: 1 |
---|
2221 | } |
---|
2222 | }), |
---|
2223 | new OpenLayers.Rule({ |
---|
2224 | title: "All", |
---|
2225 | minScaleDenominator: 3000000, |
---|
2226 | symbolizer: { |
---|
2227 | graphicName: "star", |
---|
2228 | pointRadius: 5, |
---|
2229 | fillColor: "#99ccff", |
---|
2230 | strokeColor: "#666666", |
---|
2231 | strokeWidth: 1 |
---|
2232 | } |
---|
2233 | }) |
---|
2234 | ]; |
---|
2235 | |
---|
2236 | var imagery = new OpenLayers.Layer.WMS( |
---|
2237 | "Imagery", |
---|
2238 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
2239 | {layers: "bluemarble"}, |
---|
2240 | {displayInLayerSwitcher: false} |
---|
2241 | ); |
---|
2242 | |
---|
2243 | var summits = new OpenLayers.Layer.Vector("Summits", { |
---|
2244 | strategies: [new OpenLayers.Strategy.Fixed()], |
---|
2245 | protocol: new OpenLayers.Protocol.HTTP({ |
---|
2246 | url: "data/summits.json", |
---|
2247 | format: new OpenLayers.Format.GeoJSON() |
---|
2248 | }), |
---|
2249 | styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({}, {rules: rules})) |
---|
2250 | }); |
---|
2251 | |
---|
2252 | mapPanel = new GeoExt.MapPanel({ |
---|
2253 | renderTo: "mappanel", |
---|
2254 | border: false, |
---|
2255 | layers: [imagery, summits], |
---|
2256 | center: [6.3, 45.6], |
---|
2257 | height: 256, // IE6 wants this |
---|
2258 | zoom: 8 |
---|
2259 | }); |
---|
2260 | |
---|
2261 | legendPanel = new GeoExt.LegendPanel({ |
---|
2262 | layerStore: mapPanel.layers, |
---|
2263 | renderTo: "legend", |
---|
2264 | border: false |
---|
2265 | }); |
---|
2266 | |
---|
2267 | }); |
---|
2268 | /** |
---|
2269 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
2270 | * |
---|
2271 | * Published under the BSD license. |
---|
2272 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
2273 | * of the license. |
---|
2274 | */ |
---|
2275 | |
---|
2276 | |
---|
2277 | /** api: example[wms-capabilities] |
---|
2278 | * WMS Capabilities Store |
---|
2279 | * ---------------------- |
---|
2280 | * Create layer records from WMS capabilities documents. |
---|
2281 | */ |
---|
2282 | |
---|
2283 | var store; |
---|
2284 | Ext.onReady(function() { |
---|
2285 | |
---|
2286 | // create a new WMS capabilities store |
---|
2287 | store = new GeoExt.data.WMSCapabilitiesStore({ |
---|
2288 | url: "data/wmscap.xml" |
---|
2289 | }); |
---|
2290 | // load the store with records derived from the doc at the above url |
---|
2291 | store.load(); |
---|
2292 | |
---|
2293 | // create a grid to display records from the store |
---|
2294 | var grid = new Ext.grid.GridPanel({ |
---|
2295 | title: "WMS Capabilities", |
---|
2296 | store: store, |
---|
2297 | columns: [ |
---|
2298 | {header: "Title", dataIndex: "title", sortable: true}, |
---|
2299 | {header: "Name", dataIndex: "name", sortable: true}, |
---|
2300 | {header: "Queryable", dataIndex: "queryable", sortable: true, width: 70}, |
---|
2301 | {id: "description", header: "Description", dataIndex: "abstract"} |
---|
2302 | ], |
---|
2303 | autoExpandColumn: "description", |
---|
2304 | renderTo: "capgrid", |
---|
2305 | height: 300, |
---|
2306 | width: 650, |
---|
2307 | listeners: { |
---|
2308 | rowdblclick: mapPreview |
---|
2309 | } |
---|
2310 | }); |
---|
2311 | |
---|
2312 | function mapPreview(grid, index) { |
---|
2313 | var record = grid.getStore().getAt(index); |
---|
2314 | var layer = record.getLayer().clone(); |
---|
2315 | |
---|
2316 | var win = new Ext.Window({ |
---|
2317 | title: "Preview: " + record.get("title"), |
---|
2318 | width: 512, |
---|
2319 | height: 256, |
---|
2320 | layout: "fit", |
---|
2321 | items: [{ |
---|
2322 | xtype: "gx_mappanel", |
---|
2323 | layers: [layer], |
---|
2324 | extent: record.get("llbbox") |
---|
2325 | }] |
---|
2326 | }); |
---|
2327 | win.show(); |
---|
2328 | } |
---|
2329 | |
---|
2330 | }); |
---|
2331 | /** |
---|
2332 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
2333 | * |
---|
2334 | * Published under the BSD license. |
---|
2335 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
2336 | * of the license. |
---|
2337 | */ |
---|
2338 | |
---|
2339 | /** api: example[wms-tree] |
---|
2340 | * WMS Capabilities Tree |
---|
2341 | * --------------------- |
---|
2342 | * Create a tree loader from WMS capabilities documents. |
---|
2343 | */ |
---|
2344 | var tree, mapPanel; |
---|
2345 | |
---|
2346 | Ext.onReady(function() { |
---|
2347 | |
---|
2348 | var root = new Ext.tree.AsyncTreeNode({ |
---|
2349 | text: 'GeoServer Demo WMS', |
---|
2350 | loader: new GeoExt.tree.WMSCapabilitiesLoader({ |
---|
2351 | url: 'data/wmscap.xml', |
---|
2352 | layerOptions: {buffer: 0, singleTile: true, ratio: 1}, |
---|
2353 | layerParams: {'TRANSPARENT': 'TRUE'}, |
---|
2354 | // customize the createNode method to add a checkbox to nodes |
---|
2355 | createNode: function(attr) { |
---|
2356 | attr.checked = attr.leaf ? false : undefined; |
---|
2357 | return GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]); |
---|
2358 | } |
---|
2359 | }) |
---|
2360 | }); |
---|
2361 | |
---|
2362 | tree = new Ext.tree.TreePanel({ |
---|
2363 | root: root, |
---|
2364 | region: 'west', |
---|
2365 | width: 250, |
---|
2366 | listeners: { |
---|
2367 | // Add layers to the map when ckecked, remove when unchecked. |
---|
2368 | // Note that this does not take care of maintaining the layer |
---|
2369 | // order on the map. |
---|
2370 | 'checkchange': function(node, checked) { |
---|
2371 | if (checked === true) { |
---|
2372 | mapPanel.map.addLayer(node.attributes.layer); |
---|
2373 | } else { |
---|
2374 | mapPanel.map.removeLayer(node.attributes.layer); |
---|
2375 | } |
---|
2376 | } |
---|
2377 | } |
---|
2378 | }); |
---|
2379 | |
---|
2380 | mapPanel = new GeoExt.MapPanel({ |
---|
2381 | zoom: 2, |
---|
2382 | layers: [ |
---|
2383 | new OpenLayers.Layer.WMS("Global Imagery", |
---|
2384 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
2385 | {layers: "bluemarble"}, |
---|
2386 | {buffer: 0} |
---|
2387 | ) |
---|
2388 | ], |
---|
2389 | region: 'center' |
---|
2390 | }); |
---|
2391 | |
---|
2392 | new Ext.Viewport({ |
---|
2393 | layout: "fit", |
---|
2394 | hideBorders: true, |
---|
2395 | items: { |
---|
2396 | layout: "border", |
---|
2397 | deferredRender: false, |
---|
2398 | items: [mapPanel, tree, { |
---|
2399 | contentEl: "desc", |
---|
2400 | region: "east", |
---|
2401 | bodyStyle: {"padding": "5px"}, |
---|
2402 | collapsible: true, |
---|
2403 | collapseMode: "mini", |
---|
2404 | split: true, |
---|
2405 | width: 200, |
---|
2406 | title: "Description" |
---|
2407 | }] |
---|
2408 | } |
---|
2409 | }); |
---|
2410 | |
---|
2411 | }); |
---|
2412 | /** |
---|
2413 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
2414 | * |
---|
2415 | * Published under the BSD license. |
---|
2416 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
2417 | * of the license. |
---|
2418 | */ |
---|
2419 | |
---|
2420 | /** api: example[zoom-chooser] |
---|
2421 | * Scale Chooser |
---|
2422 | * ------------- |
---|
2423 | * Use a ComboBox to display available map scales. |
---|
2424 | */ |
---|
2425 | |
---|
2426 | var mapPanel; |
---|
2427 | |
---|
2428 | Ext.onReady(function() { |
---|
2429 | var map = new OpenLayers.Map(); |
---|
2430 | var layer = new OpenLayers.Layer.WMS( |
---|
2431 | "Global Imagery", |
---|
2432 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
2433 | {layers: "bluemarble"} |
---|
2434 | ); |
---|
2435 | map.addLayer(layer); |
---|
2436 | |
---|
2437 | var scaleStore = new GeoExt.data.ScaleStore({map: map}); |
---|
2438 | var zoomSelector = new Ext.form.ComboBox({ |
---|
2439 | store: scaleStore, |
---|
2440 | emptyText: "Zoom Level", |
---|
2441 | tpl: '<tpl for="."><div class="x-combo-list-item">1 : {[parseInt(values.scale)]}</div></tpl>', |
---|
2442 | editable: false, |
---|
2443 | triggerAction: 'all', // needed so that the combo box doesn't filter by its current content |
---|
2444 | mode: 'local' // keep the combo box from forcing a lot of unneeded data refreshes |
---|
2445 | }); |
---|
2446 | |
---|
2447 | zoomSelector.on('select', |
---|
2448 | function(combo, record, index) { |
---|
2449 | map.zoomTo(record.data.level); |
---|
2450 | }, |
---|
2451 | this |
---|
2452 | ); |
---|
2453 | |
---|
2454 | map.events.register('zoomend', this, function() { |
---|
2455 | var scale = scaleStore.queryBy(function(record){ |
---|
2456 | return this.map.getZoom() == record.data.level; |
---|
2457 | }); |
---|
2458 | |
---|
2459 | if (scale.length > 0) { |
---|
2460 | scale = scale.items[0]; |
---|
2461 | zoomSelector.setValue("1 : " + parseInt(scale.data.scale)); |
---|
2462 | } else { |
---|
2463 | if (!zoomSelector.rendered) return; |
---|
2464 | zoomSelector.clearValue(); |
---|
2465 | } |
---|
2466 | }); |
---|
2467 | |
---|
2468 | mapPanel = new GeoExt.MapPanel({ |
---|
2469 | title: "GeoExt MapPanel", |
---|
2470 | renderTo: "mappanel", |
---|
2471 | height: 400, |
---|
2472 | width: 600, |
---|
2473 | map: map, |
---|
2474 | center: new OpenLayers.LonLat(5, 45), |
---|
2475 | zoom: 4, |
---|
2476 | bbar: [zoomSelector] |
---|
2477 | }); |
---|
2478 | }); |
---|
2479 | |
---|
2480 | /** |
---|
2481 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
2482 | * |
---|
2483 | * Published under the BSD license. |
---|
2484 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
2485 | * of the license. |
---|
2486 | */ |
---|
2487 | |
---|
2488 | /** api: example[zoomslider] |
---|
2489 | * Zoom Slider |
---|
2490 | * ----------- |
---|
2491 | * Use a slider to control map scale. |
---|
2492 | */ |
---|
2493 | |
---|
2494 | var panel, slider; |
---|
2495 | |
---|
2496 | Ext.onReady(function() { |
---|
2497 | |
---|
2498 | // create a map panel with an embedded slider |
---|
2499 | panel = new GeoExt.MapPanel({ |
---|
2500 | title: "Map", |
---|
2501 | renderTo: "map-container", |
---|
2502 | height: 300, |
---|
2503 | width: 400, |
---|
2504 | map: { |
---|
2505 | controls: [new OpenLayers.Control.Navigation()] |
---|
2506 | }, |
---|
2507 | layers: [new OpenLayers.Layer.WMS( |
---|
2508 | "Global Imagery", |
---|
2509 | "http://maps.opengeo.org/geowebcache/service/wms", |
---|
2510 | {layers: "bluemarble"} |
---|
2511 | )], |
---|
2512 | extent: [-5, 35, 15, 55], |
---|
2513 | items: [{ |
---|
2514 | xtype: "gx_zoomslider", |
---|
2515 | vertical: true, |
---|
2516 | height: 100, |
---|
2517 | x: 10, |
---|
2518 | y: 20, |
---|
2519 | plugins: new GeoExt.ZoomSliderTip() |
---|
2520 | }] |
---|
2521 | }); |
---|
2522 | |
---|
2523 | // create a separate slider bound to the map but displayed elsewhere |
---|
2524 | slider = new GeoExt.ZoomSlider({ |
---|
2525 | map: panel.map, |
---|
2526 | aggressive: true, |
---|
2527 | width: 200, |
---|
2528 | plugins: new GeoExt.ZoomSliderTip({ |
---|
2529 | template: "<div>Zoom Level: {zoom}</div>" |
---|
2530 | }), |
---|
2531 | renderTo: document.body |
---|
2532 | }); |
---|
2533 | |
---|
2534 | }); |
---|