source:
trunk/workshop-routing-foss4g/web/GeoExt/examples/vector-legend.js
@
80
Revision 76, 3.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[vector-legend] |
10 | * Vector Legend |
11 | * ------------------------- |
12 | * Render a legend for a vector layer. |
13 | */ |
14 | |
15 | var mapPanel, legendPanel; |
16 | |
17 | Ext.onReady(function() { |
18 | |
19 | var rules = [ |
20 | new OpenLayers.Rule({ |
21 | title: "> 2000m", |
22 | maxScaleDenominator: 3000000, |
23 | filter: new OpenLayers.Filter.Comparison({ |
24 | type: OpenLayers.Filter.Comparison.GREATER_THAN, |
25 | property: "elevation", |
26 | value: 2000 |
27 | }), |
28 | symbolizer: { |
29 | graphicName: "star", |
30 | pointRadius: 8, |
31 | fillColor: "#99ccff", |
32 | strokeColor: "#666666", |
33 | strokeWidth: 1 |
34 | } |
35 | }), |
36 | new OpenLayers.Rule({ |
37 | title: "1500 - 2000m", |
38 | maxScaleDenominator: 3000000, |
39 | filter: new OpenLayers.Filter.Comparison({ |
40 | type: OpenLayers.Filter.Comparison.BETWEEN, |
41 | property: "elevation", |
42 | upperBoundary: 2000, |
43 | lowerBoundary: 1500 |
44 | }), |
45 | symbolizer: { |
46 | graphicName: "star", |
47 | pointRadius: 6, |
48 | fillColor: "#6699cc", |
49 | strokeColor: "#666666", |
50 | strokeWidth: 1 |
51 | } |
52 | }), |
53 | new OpenLayers.Rule({ |
54 | title: "< 1500m", |
55 | maxScaleDenominator: 3000000, |
56 | filter: new OpenLayers.Filter.Comparison({ |
57 | type: OpenLayers.Filter.Comparison.LESS_THAN, |
58 | property: "elevation", |
59 | value: 1500 |
60 | }), |
61 | symbolizer: { |
62 | graphicName: "star", |
63 | pointRadius: 4, |
64 | fillColor: "#0033cc", |
65 | strokeColor: "#666666", |
66 | strokeWidth: 1 |
67 | } |
68 | }), |
69 | new OpenLayers.Rule({ |
70 | title: "All", |
71 | minScaleDenominator: 3000000, |
72 | symbolizer: { |
73 | graphicName: "star", |
74 | pointRadius: 5, |
75 | fillColor: "#99ccff", |
76 | strokeColor: "#666666", |
77 | strokeWidth: 1 |
78 | } |
79 | }) |
80 | ]; |
81 | |
82 | var imagery = new OpenLayers.Layer.WMS( |
83 | "Imagery", |
84 | "http://maps.opengeo.org/geowebcache/service/wms", |
85 | {layers: "bluemarble"}, |
86 | {displayInLayerSwitcher: false} |
87 | ); |
88 | |
89 | var summits = new OpenLayers.Layer.Vector("Summits", { |
90 | strategies: [new OpenLayers.Strategy.Fixed()], |
91 | protocol: new OpenLayers.Protocol.HTTP({ |
92 | url: "data/summits.json", |
93 | format: new OpenLayers.Format.GeoJSON() |
94 | }), |
95 | styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({}, {rules: rules})) |
96 | }); |
97 | |
98 | mapPanel = new GeoExt.MapPanel({ |
99 | renderTo: "mappanel", |
100 | border: false, |
101 | layers: [imagery, summits], |
102 | center: [6.3, 45.6], |
103 | height: 256, // IE6 wants this |
104 | zoom: 8 |
105 | }); |
106 | |
107 | legendPanel = new GeoExt.LegendPanel({ |
108 | layerStore: mapPanel.layers, |
109 | renderTo: "legend", |
110 | border: false |
111 | }); |
112 | |
113 | }); |
Note: See TracBrowser
for help on using the repository browser.