-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.html
69 lines (55 loc) · 2.18 KB
/
ajax.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=1024, user-scalable=no">
<style>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0;}
#map{ height: 100% }
</style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script type="text/javascript" src="leaflet.ajax.js"></script>
<title>Leaflet AJAX</title>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">var m= L.map('map').setView([53.4862430, -1.8904010], 6);
var mapQuestAttr = 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> — ';
var osmDataAttr = 'Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
var mopt = {
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpeg',
options: {attribution:mapQuestAttr + osmDataAttr, subdomains:'1234'}
};
var osm = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:osmDataAttr});
var mq=L.tileLayer(mopt.url,mopt.options);
mq.addTo(m);
var baseMaps = {
"Map Quest": mq,
"Open Street Map":osm
};
function popUp(f,l){
var out = [];
if (f.properties){
for(key in f.properties){
out.push(key+": "+f.properties[key]);
}
l.bindPopup(out.join("<br />"));
}
}
var jsonTest = new L.GeoJSON.AJAX("bookings.json",{onEachFeature:popUp});
//var jsonpTest = L.geoJson.ajax("heat.json",{onEachFeature:popUp,dataType:"jsonp"});
jsonTest.addTo(m);
var overlays={
"json":jsonTest
}
var lc=L.control.layers(baseMaps,overlays);
lc.addTo(m);
</script>
</body>
</html>