-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdc_viz.html
105 lines (88 loc) · 3.26 KB
/
dc_viz.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<!-- Leaflet demo adapted from these sources:
http://zevross.com/blog/2014/10/28/tips-for-creating-leafleft-js-maps/
http://leafletjs.com/examples/geojson.html -->
<html>
<head>
<title>Swigert- CP 255 Craigslist Scraping Demo</title>
<link rel='stylesheet' href='http://cdn.leafletjs.com/leaflet-0.7/leaflet.css' />
<script src='http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js'></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.js'></script>
<script src='https://code.jquery.com/jquery-2.1.1.js'></script>
<!************************************************
// ADD THE 'js' VERSION OF YOUR GEOJSON FILE HERE
//************************************************!>
<script src='dc_data.js'></script>
<style type='text/css'>
body {
margin: 0;
padding: 0;
font-family: Helvetica, sans-serif;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
#overlay {
position: absolute;
top: 10px;
left: 80px;
padding: 20px;
background-color: rgba(255,255,255,0.9);
font-size: 24px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="overlay">Swigert-Craigslist Rentals in DC Area</div>
<script type="text/javascript">
//*********************************************************
// EDIT 'spatial.b625e395' TO CHANGE THE MAPBOX BASE LAYER
//*********************************************************
var mapboxTiles = L.tileLayer('https://{s}.tiles.mapbox.com/v3/aj.03e9e12d/{z}/{x}/{y}.png', {
attribution: '<a href="http://www.mapbox.com/about/maps/" target="_blank">Terms & Feedback</a>'
});
var map = L.map('map')
.addLayer(mapboxTiles)
.setView([37.8, -122.3], 10);
//***********************************************
// EDIT THESE OPTIONS TO CHANGE THE MARKER STYLE
//***********************************************
var greenMarkerOptions = {
radius: 8,
fillColor: 'green',
fillOpacity: 0.8,
color: 'black',
opacity: 1,
weight: 1
};
//***************************************************************************
// CHANGE 'muni_tweets' TO THE VAR NAME FROM THE 'js' COPY OF YOUR DATA FILE
//***************************************************************************
var postings = L.geoJson(dc_data, {
onEachFeature: markerSetup,
pointToLayer: function (feature, latlng) {
return L.circleMarker(jitter(latlng), greenMarkerOptions);
}
});
postings.addTo(map);
map.fitBounds(postings.getBounds(), { padding: [10, 10] });
function markerSetup(feature, layer) {
if (feature.properties && feature.properties.neighborhood) {
layer.bindPopup("Neighborhood: " + feature.properties.neighborhood + '<br>'
+ "Price: " + feature.properties.price + '<br>'
+ "Sqft: " + feature.properties.sqft);
}
}
function jitter(latlng) {
var lat = latlng.lat + (Math.random()-0.5)/500;
var lng = latlng.lng + (Math.random()-0.5)/500;
return L.latLng(lat, lng);
}
</script>
</body>
</html>