This repository has been archived by the owner on Jun 22, 2020. It is now read-only.
forked from geoext/geoext1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector-legend.js
113 lines (104 loc) · 3.24 KB
/
vector-legend.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* Copyright (c) 2008-2012 The Open Source Geospatial Foundation
*
* Published under the BSD license.
* See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
* of the license.
*/
/** api: example[vector-legend]
* Vector Legend
* -------------------------
* Render a legend for a vector layer.
*/
var mapPanel, legendPanel;
Ext.onReady(function() {
var rules = [
new OpenLayers.Rule({
title: "> 2000m",
maxScaleDenominator: 3000000,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.GREATER_THAN,
property: "elevation",
value: 2000
}),
symbolizer: {
graphicName: "star",
pointRadius: 8,
fillColor: "#99ccff",
strokeColor: "#666666",
strokeWidth: 1
}
}),
new OpenLayers.Rule({
title: "1500 - 2000m",
maxScaleDenominator: 3000000,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.BETWEEN,
property: "elevation",
upperBoundary: 2000,
lowerBoundary: 1500
}),
symbolizer: {
graphicName: "star",
pointRadius: 6,
fillColor: "#6699cc",
strokeColor: "#666666",
strokeWidth: 1
}
}),
new OpenLayers.Rule({
title: "< 1500m",
maxScaleDenominator: 3000000,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LESS_THAN,
property: "elevation",
value: 1500
}),
symbolizer: {
graphicName: "star",
pointRadius: 4,
fillColor: "#0033cc",
strokeColor: "#666666",
strokeWidth: 1
}
}),
new OpenLayers.Rule({
title: "All",
minScaleDenominator: 3000000,
symbolizer: {
graphicName: "star",
pointRadius: 5,
fillColor: "#99ccff",
strokeColor: "#666666",
strokeWidth: 1
}
})
];
var imagery = new OpenLayers.Layer.WMS(
"Imagery",
"http://maps.opengeo.org/geowebcache/service/wms",
{layers: "bluemarble"},
{displayInLayerSwitcher: false}
);
var summits = new OpenLayers.Layer.Vector("Summits", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "data/summits.json",
format: new OpenLayers.Format.GeoJSON()
}),
styleMap: new OpenLayers.StyleMap(new OpenLayers.Style({}, {rules: rules}))
});
mapPanel = new GeoExt.MapPanel({
renderTo: "mappanel",
border: false,
layers: [imagery, summits],
center: [6.3, 45.6],
height: 256, // IE6 wants this
zoom: 8
});
legendPanel = new GeoExt.LegendPanel({
layerStore: mapPanel.layers,
renderTo: "legend",
border: false
});
});