-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
187 lines (170 loc) · 9.5 KB
/
index.html
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>NPRloket</title>
<link rel="stylesheet" href="theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="proj4js-compressed.js"></script>
<script src="OpenLayers.js"></script>
<script type="text/javascript">
var map, popup;
var fromProjection = new OpenLayers.Projection("EPSG:28992"); // Transform from RD
var wgs84 = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
function createFeaturesFromVivaldi(item) {
var type = this.getElementsByTagNameNS(item, "http://www.vialis.nl/vivaldi", "Type");
if (type.length == 1 && type[0].firstChild.nodeValue == "parking") {
var feature = OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply(this, arguments);
feature.attributes.title = this.getElementsByTagNameNS(item, "http://www.vialis.nl/vivaldi", "Name")[0].firstChild.nodeValue;
feature.attributes.description = type[0].firstChild.nodeValue;
feature.attributes.vehiclecount = this.getElementsByTagNameNS(item, "http://www.vialis.nl/vivaldi", "vehiclecount")[0].firstChild.nodeValue;
feature.attributes.capacity = this.getElementsByTagNameNS(item, "http://www.vialis.nl/vivaldi", "capacity")[0].firstChild.nodeValue;
feature.attributes.occupancy = this.getElementsByTagNameNS(item, "http://www.vialis.nl/vivaldi", "occupancy")[0].firstChild.nodeValue;
return feature;
} else {
return false;
}
}
function createFeaturesFromVivaldi2(item) {
var type = this.getElementsByTagNameNS(item, "http://www.vialis.nl/v2", "Type");
if (type.length == 1 && type[0].firstChild.nodeValue == "parkinglocation") {
var feature = OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply(this, arguments);
feature.attributes.title = this.getElementsByTagNameNS(item, "http://www.vialis.nl/v2", "Name")[0].firstChild.nodeValue;
feature.attributes.description = type[0].firstChild.nodeValue;
feature.attributes.freespaceshort = this.getElementsByTagNameNS(item, "http://www.vialis.nl/v2", "FreeSpaceShort")[0].firstChild.nodeValue;
feature.attributes.freespacelong = this.getElementsByTagNameNS(item, "http://www.vialis.nl/v2", "FreeSpaceLong")[0].firstChild.nodeValue;
feature.attributes.shortcapacity = this.getElementsByTagNameNS(item, "http://www.vialis.nl/v2", "ShortCapacity")[0].firstChild.nodeValue;
feature.attributes.longcapacity = this.getElementsByTagNameNS(item, "http://www.vialis.nl/v2", "LongCapacity")[0].firstChild.nodeValue;
return feature;
} else {
return false;
}
}
function init(){
var lat = 52.07;
var lon = 5.2;
var zoom = 4;
var map_controls = [new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanPanel(), new OpenLayers.Control.ZoomPanel(), new OpenLayers.Control.LayerSwitcher()];
map = new OpenLayers.Map('map', {
controls: map_controls,
maxExtent: new OpenLayers.Bounds(-285401.92,22598.08,595401.9199999999,903401.9199999999),
resolutions: [3440.64, 1720.32, 860.16, 430.08, 215.04, 107.52, 53.76,26.88, 13.44, 6.72, 3.36, 1.68, 0.84, 0.42, 0.21],
units: 'm',
numZoomLevels: 15,
projection: fromProjection,
featureEvents: true
});
var matrixIds = [];
for(var i=0; i<15; ++i) {
matrixIds[i]='EPSG:28992:'+i;
}
var resolutions = [3440.64, 1720.32, 860.16, 430.08, 215.04, 107.52, 53.76, 26.88, 13.44, 6.72, 3.36, 1.68, 0.84, 0.42, 0.21];
var lPDOK = new OpenLayers.Layer.TMS(
'BRT achtergrondkaart',
'http://geodata.nationaalgeoregister.nl/tms/',
{
layername: 'brtachtergrondkaart',
isBaseLayer: true,
displayInLayerSwitcher: true,
type: 'png8',
matrixSet: 'EPSG:28992',
matrixIds: matrixIds,
className :'olBackgroundLayer',
tileOrigin: new OpenLayers.LonLat(-285401.92,22598.08),
serverResolutions: resolutions,
tileFulExtent: new OpenLayers.Bounds (-285401.92, 22598.08,
595401.9199999999, 903401.9199999999)
}
);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var styleMap = new OpenLayers.StyleMap({'pointRadius': 6, 'externalGraphic': 'img/parking.png'});
var lAlmere = new OpenLayers.Layer.Vector("Almere", {
styleMap: styleMap,
projection: new OpenLayers.Projection("EPSG:4326"),
strategies: [new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Cluster()],
protocol: new OpenLayers.Protocol.HTTP({
url: "data/almere.xml",
format: new OpenLayers.Format.GeoRSS({createFeatureFromItem: createFeaturesFromVivaldi})
})
});
var lAmsterdam = new OpenLayers.Layer.Vector("Amsterdam", {
styleMap: styleMap,
projection: new OpenLayers.Projection("EPSG:4326"),
strategies: [new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Cluster()],
protocol: new OpenLayers.Protocol.HTTP({
url: "data/amsterdam.xml",
format: new OpenLayers.Format.GeoRSS({createFeatureFromItem: createFeaturesFromVivaldi2})
})
});
map.addLayers([lPDOK,lAlmere,lAmsterdam]);
if (!map.getCenter()) {
map.setCenter(new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:28992"), map.getProjectionObject()), zoom);
}
selectControl = new OpenLayers.Control.SelectFeature(
[lAlmere,lAmsterdam],
{
clickout: true, toggle: false,
multiple: false, hover: false,
toggleKey: "ctrlKey", // ctrl key removes from selection
multipleKey: "shiftKey" // shift key adds to selection
}
);
map.addControl(selectControl);
selectControl.activate();
lAlmere.events.on({
"featureselected": function(e) {
var feature = e.feature.cluster[0];
var pos = feature.geometry;
if (popup) {
map.removePopup(popup);
}
var title = feature.attributes.title;
var content = "";
popup = new OpenLayers.Popup("popup",
new OpenLayers.LonLat(pos.x, pos.y),
new OpenLayers.Size(200,120),
"<h3>" + title.substr(title.indexOf(' ')+1) + "</h3>" +
"<h4>" + title.substr(0,title.indexOf(' ')) + "</h4>" +
'<div style="text-align: right">'+
"vehiclecount: " + feature.attributes.vehiclecount + "<br />" +
"capacity: " + feature.attributes.capacity + "<br />" +
"occupancy: " + feature.attributes.occupancy + "</div>",
true);
popup.className = "olPopup";
map.addPopup(popup);
}
});
lAmsterdam.events.on({
"featureselected": function(e) {
var feature = e.feature.cluster[0];
var pos = feature.geometry;
if (popup) {
map.removePopup(popup);
}
var title = feature.attributes.title;
var content = "";
popup = new OpenLayers.Popup("popup",
new OpenLayers.LonLat(pos.x, pos.y),
new OpenLayers.Size(200,120),
"<h3>" + title.substr(title.indexOf(' ')+1) + "</h3>" +
"<h4>" + title.substr(0,title.indexOf(' ')) + "</h4>" +
'<div style="text-align: right">'+
"freespaceshort: " + feature.attributes.freespaceshort + "<br />" +
"shortcapacity: " + feature.attributes.shortcapacity + "<br />" +
"freespacelong: " + feature.attributes.freespacelong + "<br />" +
"longcapacity: " + feature.attributes.longcapacity + "</div>",
true);
popup.className = "olPopup";
map.addPopup(popup);
}
});
}
</script>
</head>
<body onload="init();">
<div id="map"></div>
<div id="colofon"><a href="http://twitter.com/NPRloket">@NPRloket</a> - <a href="http://data.nprloket.nl/">Open Data</a></div>
</body>
</html>