/
index.html
74 lines (56 loc) · 2.13 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Lizard Evacuation - Demo</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.ie.css" />
<![endif]-->
<style type="text/css" media="screen">
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
}
</style>
<script src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js"></script>
<script src="http://code.jquery.com/jquery.min.js"></script>
</head>
<body id="index" onload="">
<div id="map"></div>
<script>
var map = L.map('map');
L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>'
}).addTo(map);
function showPopup(obj) {
var geobj = obj.reverseGeoResponse.reverseGeoResult;
var radius = 40;
console.log(geobj);
latlong = new L.LatLng(geobj.latitude, geobj.longitude);
L.marker(latlong).addTo(map)
.bindPopup("You are within " + radius + " meters from " + geobj.formattedAddress).openPopup();
L.circle(latlong, radius).addTo(map);
}
function onLocationFound(e) {
var radius = e.accuracy / 2;
$.ajax({
url: 'https://api.tomtom.com/lbs/services/reverseGeocode/3/jsonp?point=52.092747763124976%2C5.115900219999986&jsonp=showPopup&key=aztb7b4z64svu56d3wbvqd35',
dataType: 'jsonp',
jsonpCallbackString: 'showPopup'
});
}
function onLocationError(e) {
alert(e.message);
}
map.on('locationfound', onLocationFound);
map.on('locationerror', onLocationError);
map.locate({setView: true, maxZoom: 16});
</script>
</body>
</html>