-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfarmers_markets.html
81 lines (71 loc) · 2.51 KB
/
farmers_markets.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
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<title>Farmer's Markets</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
</head>
<body>
<div id="map"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script>
// center on City Hall
var map = L.map('map').setView([39.952707, -75.163431], 15);
// use higher resolution map tiles on retina devices
var retina = '';
if (window.devicePixelRatio > 1) {
retina = '@2x';
}
// add base layer
L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}' + retina + '.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, ' +
'© <a href="http://cartodb.com/attributions">CartoDB</a>'
}).addTo(map);
function makePopups(feature, layer) {
var popupContent = ['<h3>' + feature.properties.NAME + '</h3>',
'<p>' + feature.properties.ADDRESS + '<br />',
feature.properties.TIME + ' ' + feature.properties.DAY + '<br />',
feature.properties.MONTHS + '</p>'
].join('');
if (feature.properties.ACCEPT_SNAP_ACCESS == 'Y') {
popupContent += '<p>Accepts food stamps.</p>';
}
layer.bindPopup(popupContent);
}
$.ajax({
url: 'http://data.phl.opendata.arcgis.com/datasets/0707c1f31e2446e881d680b0a5ee54bc_0.geojson',
dataType: 'json',
crossDomain: true,
success: function(json) {
// add the GeoJSON layer
L.geoJson([json], {
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, {
radius: 5,
fillColor: "blue",
color: "blue",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
},
onEachFeature: makePopups
}).addTo(map);
}, error: function(error) {
console.error('Hm, something went wrong.');
console.error(error);
}
});
</script>
</body>
</html>