-
Notifications
You must be signed in to change notification settings - Fork 156
/
common-script.js
131 lines (109 loc) · 4.13 KB
/
common-script.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
PublicaMundi.noConflict();
//Popup handling with Bootstrap
var onFeatureClick = function(features, coordinate) {
if (features) {
feature = features [0];
}
if (popup) {
map.setOverlayPosition(popup, coordinate);
$(document.getElementById('popup')).popover('destroy');
var text = JSON.stringify(feature);
$(document.getElementById('popup')).popover({
'placement' : 'top',
'animation' : true,
'html' : true,
'content' : text
}).attr('data-original-title');
$(document.getElementById('popup')).popover('show');
}
};
// Map initialization options
var options = {
target: 'map',
center: [2548716, 4643375],
zoom: 6,
minZoom: 2,
maxZoom: 18,
layerControl: true,
layers: [
{
title: 'Open Street Maps',
switcher: 'base',
type: PublicaMundi.LayerType.TILE,
url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
}
]
};
var map, popup;
PublicaMundi.ready(function () {
//Initialize map with provided options
map = PublicaMundi.map(options);
//Initialize popup handler
popup = map.addOverlay(document.getElementById('popup'));
$(document.getElementById('map')).click(function() {
$(document.getElementById('popup')).popover('destroy');
});
//Add layers
// WMS Railway Layer
var railway = map.createLayer({
title: 'Railway Network',
name: 'railway',
type: PublicaMundi.LayerType.WMS,
visible: true,
url: 'http://labs.geodata.gov.gr/geoserver/wms',
params: { 'layers' : 'publicamundi:c0b70f0a-515d-4a0a-a894-abc412d5239e',
},
});
// KML Ancient theaters Layer
var theaters = map.createLayer({
title: 'Ancient Theaters',
name: 'theaters',
type: PublicaMundi.LayerType.KML,
click: onFeatureClick,
//center: [2548716, 4643375],
url: 'data/kml/archaia_theatra.kml',
style: {
normal:{
color: 'black',
opacity: 1,
fillColor: '#00ff00',
fillOpacity: 1
},
highlight:{
weight: 3,
radius: 10,
}
},
});
// WFS parse Capabilities and display layer with name galazies_shmaies_2010
var parser = PublicaMundi.parser();
$.ajax({
url: 'http://labs.geodata.gov.gr/geoserver/wfs?request=GetCapabilities',
}).then(function(response) {
var result = parser.parseWFS(response);
for (var idx in result.Layer){
var layer = result.Layer[idx];
if (layer.Title === 'galazies_shmaies_2008'){
map.createLayer({
title: layer.Title,
type: PublicaMundi.LayerType.WFS,
click: onFeatureClick,
url: 'http://labs.geodata.gov.gr/geoserver/wfs',
visible: false,
params: { 'layers' : layer.Name },
style:{ normal:{
color: 'black',
weight: 1,
radius: 6,
fillColor: '#87beed',
fillOpacity: 0.9
},
highlight:{
fillColor: '#095ba1',
}
}
});
}
}
});
})