forked from ryanj/restify-postGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
71 lines (63 loc) · 2.68 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
<!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">National Parks</h1>
<div id="map"></div>
<script src="//cdn.leafletjs.com/leaflet-0.5.1/leaflet.js"></script>
<script>
var map = L.map('map').setView([37.8, -122.3], 10);
var markerLayerGroup = L.layerGroup().addTo(map);
L.tileLayer('http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.png', {
maxZoom: 18,
minZoom: 5,
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.'
}).addTo(map);
function getPins(e){
bounds = map.getBounds();
url = "parks/within?lat1=" + bounds.getSouthWest().lat + "&lon1=" + bounds.getSouthWest().lng + "&lat2=" + bounds.getNorthEast().lat + "&lon2=" + bounds.getNorthEast().lng;
$.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];
markerArray[i] = L.marker([park.lat, park.lon]).bindPopup(park.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-postGIS.git&cartridges[]=nodejs-0.10&cartridges[]=postgresql-9.2">Run me on OpenShift</a></span>
</body>
</html>