-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet.utfgrid.buildings.kharkov.html
175 lines (132 loc) · 4.73 KB
/
leaflet.utfgrid.buildings.kharkov.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" sizes="25x25" href="assets/img/icon.png">
<title>Leaflet. UTF-Grid</title>
<link rel="stylesheet" href="assets/bootstrap-3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/leaflet-0.7.3/leaflet.css">
<style>
html,
body,
#container {
height: 100%;
width: 100%;
overflow: hidden;
}
#map {
position: absolute;
margin: 0px;
padding: 0;
height: 100%;
width: 100%;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.info h4 {
margin: 0 0 5px;
color: #777;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="assets/jquery-1.11.2.min.js"></script>
<script src="assets/bootstrap-3.3.2/js/bootstrap.min.js"></script>
<script src="assets/leaflet-0.7.3/leaflet.js"></script>
<script type="text/javascript" src="assets/leaflet.utfgrid/leaflet.utfgrid.js"></script>
<script>
var layerMapBoxOSM = new L.tileLayer('http://{s}.tiles.mapbox.com/v3/examples.map-20v6611k/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: 'Map style © <a href="https://www.mapbox.com/about/maps/">MapBox</a>; Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
var map = new L.Map('map', {
minZoom: 1,
maxZoom: 18,
layers: [layerMapBoxOSM]
}).setView([50.0068, 36.2319], 17);
//------------------------------------------------------------------------------------------------
var layerBuildings = L.geoJson(null, {
style: function(feature) {
return {
color: "#fd9a00",
fill: true,
opacity: 0.4,
};
},
onEachFeature: function(feature, layerbs) {
if (feature.properties) {
var contentzone = "<table class='table table-striped table-bordered table-condensed'>" +
"<tr><th>HN</th><td>" + feature.properties.addr_house + "</td></tr>"
"<table>";
layerbs.bindPopup(contentzone, {
closeButton: true,
minWidth: 120,
minHeight: 25
});
}
layerbs.on({
mouseover: function(e) {
var layerbs = e.target;
layerbs.setStyle({
weight: 3,
color: "#00FFFF",
opacity: 1
});
if (!L.Browser.ie && !L.Browser.opera) {
layerbs.bringToFront();
}
},
mouseout: function(e) {
layerBuildings.resetStyle(e.target);
}
});
}
});
$.getJSON("data/kharkov_buildings.geojson", function(data) {
layerBuildings.addData(data);
});
//layerBuildings.addTo(map);
var utfGrid = new L.UtfGrid('data/utfgrid.tiles/{z}/{x}/{y}.json', {
useJsonP: false
});
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (jsondata) {
for(var key in jsondata) {
var id = jsondata["id"];
var bl = jsondata["building_l"];
this._div.innerHTML = '<h4> Buildings Data      </h4>' + (id ? '<b>' + "osmid: " + id + '</b><br/>' + "floor: " + bl : 'Hover over a building');
};
};
info.addTo(map);
utfGrid.on('mouseover', function(e) {
if (e.data) {
info.update(e.data);
} else {
info.update();
}
});
utfGrid.on('mouseout', function(e) {
info.update();
});
map.addLayer(utfGrid);
</script>
</body>
</html>