-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet09-geojsonurldata.html
59 lines (45 loc) · 1.67 KB
/
leaflet09-geojsonurldata.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
<!DOCTYPE html>
<html>
<head>
<title>Map</title>
<!-- Load Leaflet.js and styles from a CDN -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style type="text/css">
#map {width: 100%; height: 600px;}
</style>
</head>
<body>
<!-- The div where the map goes -->
<div id="map"></div>
<!-- Map javascript -->
<script type="text/javascript">
// Create a map
var map = L.map('map')
.setView([52.2015, 0.127], 14); // Easy way to work out lat/lon/zoom is http://www.openstreetmap.org/
// Add tile background
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// Add the GeoJSON data in the file to the map
var url = 'https://api.cyclestreets.net/v2/photomap.locations';
var params = {
key: 'b2b70892933aa9a8',
limit: 50,
bbox: '0.10549,52.19501,0.14565,52.21079'
};
// Obtain over AJAX
$.ajax({
type: "GET",
data: params,
url: url,
dataType: 'json',
success: function (data) {
L.geoJson(data).addTo(map);
}
});
</script>
</body>
</html>