-
Notifications
You must be signed in to change notification settings - Fork 0
/
bboxLayer.js
77 lines (73 loc) · 2.09 KB
/
bboxLayer.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
/*
* bboxLayer is just an OpenLayers.Layer.Vector
*/
function bboxLayer() {
return new OpenLayers.Layer.Vector(
"Search Result Footprints",
{
styleMap: new OpenLayers.StyleMap({
'default': new OpenLayers.Style({
fillOpacity: 0,
strokeColor: '#3C52FA',
strokeWidth: 1
}),
'select': new OpenLayers.Style({
fillColor: '#FF6426',
fillOpacity: 0.2,
strokeColor: '#FF6426',
strokeWidth: 3
}),
'hover': new OpenLayers.Style({
strokeColor: '#16F7EC',
strokeWidth: 3
})
})
}
);
}
function addBboxControls(bboxLyr, map, resultsTable) {
// One control to highlight boxes as you hover over them
var hover = new OpenLayers.Control.SelectFeature(
bboxLyr,
{
hover: true,
highlightOnly: true,
renderIntent: "hover",
autoActivate: true,
id: 'bbox-hover-control',
eventListeners: {
featurehighlighted: function(e) {
// If the feature is selected by the other control, do not highlight it
thisFeature = e.feature;
if (bboxLyr.selectedFeatures[0] == thisFeature) {
// This just redraws the feature with the "select" style defined above
bboxLyr.drawFeature(thisFeature, 'select');
}
}
}
}
);
// Another control to actually select the features
var select = new OpenLayers.Control.SelectFeature(
bboxLyr,
{
renderIntent: "select",
autoActivate: true,
id: 'bbox-select-control',
onSelect: function(feature) {
// Select the Panel that corresponds to this bbox
store = Ext.getCmp("csw-tab-container").searchStore;
record = store.getAt(store.find('fileid', feature.attributes.fileid));
panel = store.getRecordPanel(record);
if (store.selectedPanel || false) { store.selectedPanel.removeClass("result-row-selected"); }
panel.addClass("result-row-selected");
store.selectedPanel = panel;
}
}
);
// allow mousedown events to propagate to other controls
hover.handlers.feature.stopDown = false;
select.handlers.feature.stopDown = false;
// Add the controls to the map
map.addControls([ hover, select ]);
}