forked from ryanj/restify-mongodb-parks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (67 loc) · 2.47 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
<!doctype html>
<html lang="en">
<head>
<title>Map of Parks and Historic Sites</title>
<link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.5.1/leaflet.css" />
<link rel="stylesheet" href="css/ribbon.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.5.1/leaflet.ie.css" />
<![endif]-->
<script src="//code.jquery.com/jquery-2.0.0.min.js"></script>
<link href='//fonts.googleapis.com/css?family=Milonga' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <style type="text/css">
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
font-family: 'Milonga', cursive;
}
.leaflet-container .leaflet-control-zoom {
margin-left: 13px;
margin-top: 70px;
}
#map { z-index: 1;}
#title { z-index: 2; position: absolute; left: 10px; }
</style>
</head>
<body>
<h1 id="title">Bus Stops</h1>
<div id="map"></div>
<script src="//cdn.leafletjs.com/leaflet-0.5.1/leaflet.js"></script>
<script>
var map = L.map('map').setView([-36.852747,174.764034], 14);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
var markerLayerGroup = L.layerGroup().addTo(map);
function getPins(e){
bounds = map.getBounds();
url = "parks";
$.get(url, pinTheMap, "json")
}
function pinTheMap(data){
//clear the current pins
map.removeLayer(markerLayerGroup);
//add the new pins
var markerArray = new Array(data.length)
for (var i = 0; i < data.length; i++){
park = data[i];
lat = park.stop_lat;
long = park.stop_lon;
console.log(lat, long);
markerArray[i] = L.marker([lat, long]).bindPopup(park.stop_name);
}
markerLayerGroup = L.layerGroup(markerArray).addTo(map);
}
map.on('dragend', getPins);
map.on('zoomend', getPins);
map.whenReady(getPins)
</script>
<span id="fossribbon"><a href="https://openshift.redhat.com/app/console/application_types/custom?name=parks&initial_git_url=https%3A%2F%2Fgithub.com/ryanj/restify-mongodb-parks.git&cartridges[]=nodejs-0.10&cartridges[]=mongodb-2.2">Run me on OpenShift</a></span>
</body>
</html>