-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
197 lines (176 loc) · 8.72 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
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE HTML>
<html>
<head>
<title>OpenLayers Demo</title>
<style type="text/css">
html, body, #Map {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<script src="OpenLayers.js"></script>
<script>
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
initialize: function(options) {
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
this, arguments
);
this.handler = new OpenLayers.Handler.Click(
this, {
'click': this.trigger
}, this.handlerOptions
);
},
trigger: function(e) {
var lonlat = map.getLonLatFromPixel(e.xy);
//alert("You clicked near " + lonlat.lat + " N, " +
// + lonlat.lon + " E");
window.open('http://vmjacobsen34.informatik.tu-muenchen.de/import?lat=' + lonlat.lat + '&lon=' + lonlat.lon, '_blank', '');
}
});
var map;
var fromProjection = new OpenLayers.Projection("EPSG:4326"); // transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
var extent = new OpenLayers.Bounds(10.739,47.503,13.046,49).transform(fromProjection,toProjection);
function init() {
var options = {
restrictedExtent : extent,
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Permalink({anchor: true}),
new OpenLayers.Control.MousePosition({prefix: 'EPSG:4326 coordinates: '})
]
};
map = new OpenLayers.Map("Map", options);
var click = new OpenLayers.Control.Click();
map.addControl(click);
click.activate();
var newLayer = new OpenLayers.Layer.OSM("Local Tiles", "http://vmjacobsen34.informatik.tu-muenchen.de/osm/${z}/${x}/${y}.png", {opacity: 0.4}, {numZoomLevels: 19});
map.addLayer(newLayer);
var newLayer = new OpenLayers.Layer.OSM("Colored Voronoi (Transformer)", "http://vmjacobsen34.informatik.tu-muenchen.de/voronoicolored/${z}/${x}/${y}.png", {opacity: 0.2, isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer);
var newLayer2 = new OpenLayers.Layer.OSM("Voronoi (Transformer)", "http://vmjacobsen34.informatik.tu-muenchen.de/voronoi/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer2);
var newLayer3 = new OpenLayers.Layer.OSM("powerlines (Transformer)", "http://vmjacobsen34.informatik.tu-muenchen.de/powerlines/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer3);
var newLayer7 = new OpenLayers.Layer.OSM("Colored Voronoi (\"Umspannwerk\")", "http://vmjacobsen34.informatik.tu-muenchen.de/umspannwerk_voronoicolored/${z}/${x}/${y}.png", {opacity: 0.2, isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer7);
var newLayer8 = new OpenLayers.Layer.OSM("Voronoi (\"Umspannwerk\")", "http://vmjacobsen34.informatik.tu-muenchen.de/umspannwerk_voronoi/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer8);
var newLayer9 = new OpenLayers.Layer.OSM("powerlines (\"Umspannwerk\")", "http://vmjacobsen34.informatik.tu-muenchen.de/umspannwerk_powerlines/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer9);
var newLayer10 = new OpenLayers.Layer.OSM("Power Overlay", "http://vmjacobsen34.informatik.tu-muenchen.de/poweronly/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer10);
var newLayer3 = new OpenLayers.Layer.OSM("minimum spanning tree (Transformer)", "http://vmjacobsen34.informatik.tu-muenchen.de/minspantree_powerlines/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer3);
var newLayer12 = new OpenLayers.Layer.OSM("Dijkstra powerlines (Transformer)", "http://vmjacobsen34.informatik.tu-muenchen.de/dijkstra_powerlines/${z}/${x}/${y}.png",
{ isBaseLayer: false, visibility: false}, {numZoomLevels: 19} );
map.addLayer(newLayer12);
var geojson_layer = new OpenLayers.Layer.Vector("Powerlines tester", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "http://vmjacobsen34.informatik.tu-muenchen.de/powerlines.php",
format: new OpenLayers.Format.GeoJSON()
}),
style: {strokeWidth: 2, strokeColor: 'orange'},
isBaseLayer: false,
visibility: false
});
map.addLayer(geojson_layer);
layerMapnik = new OpenLayers.Layer.OSM();
map.addLayer(layerMapnik);
var switcherControl = new OpenLayers.Control.LayerSwitcher();
map.addControl(switcherControl);
switcherControl.maximizeControl();
map.setCenter(new OpenLayers.LonLat(11.65257,48.24928).transform(fromProjection,toProjection), 14); // 0=relative zoom level
}
function submitform() {
var queryString = document.forms[0].query.value;
OpenLayers.Request.GET({
url: "http://vmjacobsen34.informatik.tu-muenchen.de/nominatim/search.php",
scope: this,
failure: this.requestFailure,
success: this.requestSuccess,
params: {q: queryString, format: "json", limit: "1"}
});
}
function requestSuccess(response) {
//var format = new OpenLayers.Format.JSON();
var output = JSON.parse(response.responseText);
if (output[0]) {
var geoObject = output[0];
//alert(geoObject.lon + " / " + geoObject.lat);
//if (output.responseLists[0]) {
//var geometry = output.responseLists[0].features[0].geometry;
//var foundPosition = new OpenLayers.LonLat(geometry.x, geometry.y).transform(
//new OpenLayers.Projection("EPSG:4326"),
//map.getProjectionObject()
//);
//map.setCenter(foundPosition, 16);
//} else {
//alert("Sorry, no address found");
//}
map.setCenter(new OpenLayers.LonLat(geoObject.lon, geoObject.lat).transform(fromProjection,toProjection));
} else {
alert("Address not found");
}
}
function requestFailure(response) {
alert("An error occurred. Please try again.");
}
</script>
</head>
<body onload="init();">
<div id="Map"></div>
<form style ="position:absolute; top:10px; left:60px; z-index:1000; background-color:darkblue; color:white; padding:5px;font-weight:bold; font-family:sans-serif; font-size:smaller;" name="input" action="javascript: submitform();" method="post">
<label for="query">Address</label> <input type="text" id="query" size=35 name="query"/>
<input type="submit" value="Search"/>
</form>
<div id = "legend" style="position:absolute; bottom:0; left:0; z-index: 1000;">
<div>
<span id="toggleButton" style="background-color: white;">hide legend</span>
</div>
<img id="legendImg" src="legend.png" />
</div>
<script>
var leg = document.getElementById('legendImg');
leg.style.display = 'none';
var x = document.getElementById("toggleButton");
x.innerHTML = 'show legend';
if (x.addEventListener) { // For all major browsers, except IE 8 and earlier
x.addEventListener("click", myFunction);
} else if (x.attachEvent) { // For IE 8 and earlier versions
x.attachEvent("onclick", myFunction);
}
function myFunction() {
if (leg.style.display == 'none') {
leg.style.display = 'block';
x.innerHTML = 'hide legend';
} else {
leg.style.display = 'none';
x.innerHTML = 'show legend';
}
//leg.setAttribute('style', 'display:none;');
}
</script>
</body>
</html>