-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapLayer.js
90 lines (87 loc) · 3.02 KB
/
mapLayer.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
var mapLayer = Ext.extend(Object, {
constructor: function(type, url, name, map) {
this.type = type;
this.url = url;
this.name = name;
this.map = map;
// TODO: Remove dependency on app variable
this.app = app;
},
connect: function() {
var expander = new Ext.grid.RowExpander({
tpl: new Ext.Template("<p><b>Abstract:</b> {abstract}</p>")
});
// TODO: Adjust so that proxy location is read from OpenLayers or Viewer config
var capabilitiesUrl = "/proxy/?url=" + encodeURIComponent(this.url);// + "&request=GetCapabilities&service=WMS");
if (this.type == "wms") {
this.app.addLayerSource({
id: this.url,
config: {
ptype: "gxp_wmssource",
url: capabilitiesUrl
},
callback: function() {
Ext.getCmp(this.name + "-add-button").setIcon("csw/img/map_add.png");
source = this.app.layerSources[this.url];
layerChooser = new Ext.Window({
id: "wms-layer-chooser",
title: "WMS Layers Available",
tbar: [ "Available layers from " + source.title ],
layout: "fit",
height: 300,
width: 450,
modal: true,
items: [
new Ext.grid.GridPanel({
id: "wms-grid",
store: source.store,
autoScroll: true,
autoExpandColumn: "title",
plugins: [ expander ],
loadMask: true,
colModel: new Ext.grid.ColumnModel([
expander,
{id: "title", header: this.panelTitleText, dataIndex: "title", sortable: true},
{header: "Id", dataIndex: "name", width: 150, sortable: true}
]),
bbar: [ "->",
new Ext.Button({
text: "Add layers",
iconCls: "gxp-icon-addlayers",
source: source,
layers: this.app.mapPanel.layers,
handler: function() {
records = Ext.getCmp("wms-grid").getSelectionModel().getSelections();
var addThese = [];
for (var i=0, ii=records.length; i<ii; ++i) {
addThese.push(this.source.createLayerRecord({
name: records[i].get("name"),
source: this.source
}));
}
this.layers.add(addThese);
}
}),
new Ext.Button({
text: "Done",
handler: function() { Ext.getCmp("wms-layer-chooser").destroy(); }
})
]
})
]
});
layerChooser.show();
},
scope: this
});
} else {
// TODO: Support other formats (WFS, ESRI)
(new Ext.Window({
title: "Sorry!",
html: "<p class='window-text'>My apologies, but currently we can only add WMS Services!</p>",
width: 150
})).show();
Ext.getCmp(this.name + "-add-button").setIcon("csw/img/map_add.png");
}
}
});