-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapbox.html
50 lines (46 loc) · 1.57 KB
/
mapbox.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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>GeoJSON marker from GitHub</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { height:300px; max-width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<!-- jQuery is required for this example. -->
<script src='https://code.jquery.com/jquery-1.11.0.min.js'></script>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoibGVhcm5pbmduZXJkIiwiYSI6ImM0YzYyYjU3MTI5NmU0ZGIwOTg5NDMyMWJkYmIyNmQ1In0.0A7HsPEzc91rDR0rGRz33w';
var url = 'https://raw.githubusercontent.com/LearningNerd/learningGIS/gh-pages/lacities.geojson';
var map = L.mapbox.map('map', 'learningnerd.n6ibmhde')
.setView([0.3941, -78.2227], 7);
function load() {
// Fetch just the contents of a .geojson file from GitHub by passing
// `application/vnd.github.v3.raw` to the Accept header
// As with any other AJAX request, this technique is subject to the Same Origin Policy:
// http://en.wikipedia.org/wiki/Same_origin_policy the server delivering the request should support CORS.
$.ajax({
headers: {
'Accept': 'application/vnd.github.v3.raw'
},
xhrFields: {
withCredentials: false
},
dataType: 'json',
url: url,
success: function(geojson) {
// On success add fetched data to the map.
L.mapbox.featureLayer(geojson).addTo(map);
}
});
}
$(load);
</script>
</body>
</html>