-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
88 lines (76 loc) · 2.38 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
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta charset="utf-8"/>
<title>Adding street names</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<link rel="stylesheet" href="css/streets.css" />
<style type="text/css">
#map { height: 700px; }
.custom-popup {
}
.custom-popup .leaflet-popup-content-wrapper, .custom-popup .leaflet-popup-tip {
background: #222;
box-shadow: none;
width: 500px;
height: 500px;
}
.custom-popup .leaflet-popup-content-wrapper {
border-radius: 0;
color: #ccc;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/lib/leaflet.js"></script>
<script type="text/javascript" src="js/leaflet.d3.js"></script>
<script type="text/javascript">
window.onload = function(){
var map = L.map('map',{
maxBounds: [[46.6412301,23.4324747],[46.9201137,23.8047838]]
})
.fitBounds([[46.7412301, 23.53816],[46.76813, 23.59253]]);
//Background tiles
var AltTiles = 'http://b.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png';
var StamenTiles = 'http://a.tile.stamen.com/toner-lite/{z}/{x}/{y}.png';
L.tileLayer(AltTiles).addTo(map);
// Test streets with historical maps overlay.
var myTiles = '../historical-maps/img/1869/{z}/{x}/{y}.png';
var options = {
minZoom: 13,
maxZoom: 17,
opacity: 0.6,
tms: true
};
// L.tileLayer(myTiles, options).addTo(map);
d3.json("json/streets.json", function(collection) {
var layer = new L.D3geoJSON(collection, {
id: 'svg-streets',
featureAttributes: {
'class': function(feature) {
return 'highway-' + feature.properties.highway;
}
},
pointerEvents: 'visibleStroke'
}).addTo(map).on('click', function(e) {
var id = e.data.properties.id.replace('way/', '');
$.getJSON('json/metadata/' + id + '.json', function(resp) {
var latlng = map.mouseEventToLatLng(e.originalEvent);
var popup = L.popup({
className: 'custom-popup'
})
.setLatLng(latlng)
.setContent(resp.name)
.openOn(map);
});
});
console.log(layer._bounds);
});
};
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>