forked from Lounaispaikka/QuarterBrowser
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
124 lines (116 loc) · 3.14 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Tulevaisuuden paikkatietosovellus</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.ie.css" />
<![endif]-->
<style type="text/css">
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
</head>
<body>
<!-- HTML Div that contains our Leaflet-map --->
<div id="map"></div>
<script>
function initmap() {
// Set up the map
var map = new L.Map('map');
// Create baselayer using Open Street Map
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © OpenStreetMap contributors';
var osm = new L.TileLayer(osmUrl, {minZoom: 8, maxZoom: 20, attribution: osmAttrib});
// Set coordinates and zoom for the map view
map.setView(new L.LatLng(60.1395, 22.3160),10);
// Add OSM-baselayer
map.addLayer(osm);
var datalayer_style = {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
};
// GeoJSON is stored inside a file, fetch data using Ajax-request.
$.ajax({
type: "POST",
url: "http://users.utu.fi/faalsu/archipelago_building_cluster_grid2.geojson",
dataType: 'json',
success: function (response) {
geojsonLayer = L.geoJson(response, {
// style: datalayer_style,
style: function (feature) {
//console.log(feature.properties.L_perc);
switch(true)
{
case feature.properties.L_perc <= 0:
return {
"color": "#FFFFFF",
"weight": 0,
"opacity": 1
};
break;
case feature.properties.L_perc <= 10 :
return {
"color": "#336600",
"weight": 0,
"opacity": 0.8
};
break;
case feature.properties.L_perc <= 20 :
console.log("testi");
return {
"color": "#660099",
"weight": 0,
"opacity": 0.8
};
break;
case feature.properties.L_perc <= 30 :
return {
"color": "#330066",
"weight": 0,
"opacity": 0.8
};
break;
case feature.properties.L_perc <= 40 :
return {
"color": "#9A00FF",
"weight": 0,
"opacity": 0.8
};
break;
default:
return {
"color": "#ff0000",
"weight": 0,
"opacity": 0.0
};
}
},
onEachFeature: displayName // Bind popup to feature
}).addTo(map);
}
});
// Adds name of the area as popup
function displayName(feature, layer){
if (feature.properties.L_perc) {
layer.bindPopup(feature.properties.L_perc);
}
}
}
// Run initmap-function when site is loaded
initmap();
</script>
</body>
</html>
</body>
</html>