Last active
April 22, 2016 17:31
-
-
Save dalmat36/841eb621f5607bc85e6ec20822d18696 to your computer and use it in GitHub Desktop.
Maptime State College Meetup: Mapping Sexual Assault Data with Leaflet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leaflet Quick Start Guide Example</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leaflet Quick Start Guide Example</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css" /> | |
</head> | |
<body> | |
<div id="mapid" style="height: 400px"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> | |
<script src="residencies.js"></script> | |
<script src="SexualAssaults.js"></script> | |
<script> | |
var mymap = L.map('mapid').setView([40.803, -77.86], 14); | |
L.tileLayer('https://api.tiles.mapbox.com/v4/mapbox.dark/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA', { | |
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://mapbox.com">Mapbox</a>', | |
id: 'mapbox.streets' | |
}).addTo(mymap); | |
//add residencies | |
L.geoJson(residencies).addTo(mymap); | |
//add assault data | |
L.geoJson(assaults, { | |
onEachFeature : function(feature,layer) { | |
var popupContent = "Incidence #: " + feature.properties.IncidenNum + '<br>' + | |
"Date: " + feature.properties.Date; | |
layer.bindPopup(popupContent); | |
} | |
}).addTo(mymap); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var residencies = { | |
"type": "FeatureCollection", | |
"crs": { | |
"type": "name", | |
"properties": { | |
"name": "urn:ogc:def:crs:OGC:1.3:CRS84" | |
} | |
}, | |
"features": [ | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "South Halls" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.85946704453985, | |
40.800693556923505 | |
], | |
[ | |
-77.85712589922282, | |
40.79938912049094 | |
], | |
[ | |
-77.85556909700692, | |
40.800792513124 | |
], | |
[ | |
-77.85508185356532, | |
40.80048664802757 | |
], | |
[ | |
-77.85448765424628, | |
40.8006305847191 | |
], | |
[ | |
-77.8540241787774, | |
40.80036070316642 | |
], | |
[ | |
-77.85834994982004, | |
40.79701408074841 | |
], | |
[ | |
-77.8593125527169, | |
40.79765283085088 | |
], | |
[ | |
-77.85802908218774, | |
40.79853447582547 | |
], | |
[ | |
-77.86025138764097, | |
40.799874913606324 | |
], | |
[ | |
-77.85946704453985, | |
40.800693556923505 | |
] | |
] | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "Pollock Halls" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.85933632068968, | |
40.800783517111896 | |
], | |
[ | |
-77.85763691063718, | |
40.80251072908524 | |
], | |
[ | |
-77.85566416889796, | |
40.80254671219005 | |
], | |
[ | |
-77.85546214112951, | |
40.80125130812604 | |
], | |
[ | |
-77.85725662307303, | |
40.79957804045824 | |
], | |
[ | |
-77.85933632068968, | |
40.800783517111896 | |
] | |
] | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "Eastview Terrace" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.8555744448008, | |
40.800860882776384 | |
], | |
[ | |
-77.85530348991138, | |
40.80150859177838 | |
], | |
[ | |
-77.8534567184278, | |
40.80270143931833 | |
], | |
[ | |
-77.85154577341774, | |
40.80287415754736 | |
], | |
[ | |
-77.85127481852827, | |
40.80222646187099 | |
], | |
[ | |
-77.8515600342014, | |
40.80204834445202 | |
], | |
[ | |
-77.85191655379282, | |
40.80187562407404 | |
], | |
[ | |
-77.85393445468027, | |
40.80038589215775 | |
], | |
[ | |
-77.85446210367557, | |
40.80068276169272 | |
], | |
[ | |
-77.85505392619733, | |
40.80055861641238 | |
], | |
[ | |
-77.8555744448008, | |
40.800860882776384 | |
] | |
] | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "Nittany Apartments" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.85700884195698, | |
40.80501150843425 | |
], | |
[ | |
-77.8558869936426, | |
40.80439261929778 | |
], | |
[ | |
-77.85571586423873, | |
40.80359381199686 | |
], | |
[ | |
-77.8556873426714, | |
40.802679849508145 | |
], | |
[ | |
-77.85687574130947, | |
40.80260788342332 | |
], | |
[ | |
-77.85820674778414, | |
40.80264386647548 | |
], | |
[ | |
-77.85907190199265, | |
40.8030108924932 | |
], | |
[ | |
-77.85700884195698, | |
40.80501150843425 | |
] | |
] | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "East Halls" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.86259906915052, | |
40.80819797649005 | |
], | |
[ | |
-77.8608022104097, | |
40.807388420852114 | |
], | |
[ | |
-77.86134412018872, | |
40.80683791737704 | |
], | |
[ | |
-77.86000360652494, | |
40.806211849051465 | |
], | |
[ | |
-77.86165785742918, | |
40.80446314416514 | |
], | |
[ | |
-77.86445297102593, | |
40.80588801828963 | |
], | |
[ | |
-77.86259906915052, | |
40.80819797649005 | |
] | |
] | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "West Halls" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.8674667499721, | |
40.797311325224335 | |
], | |
[ | |
-77.86672518922194, | |
40.79681831610799 | |
], | |
[ | |
-77.86645423433245, | |
40.796974855895684 | |
], | |
[ | |
-77.8654203275173, | |
40.79624613305399 | |
], | |
[ | |
-77.86695336176044, | |
40.795117946358076 | |
], | |
[ | |
-77.8674667499721, | |
40.79547601725868 | |
], | |
[ | |
-77.86827486104602, | |
40.796105785513994 | |
], | |
[ | |
-77.86838181692343, | |
40.79642966400478 | |
], | |
[ | |
-77.86819167314135, | |
40.79676253747379 | |
], | |
[ | |
-77.8674667499721, | |
40.797311325224335 | |
] | |
] | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Hall": "North Halls" | |
}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ | |
-77.8666610156955, | |
40.803387271969775 | |
], | |
[ | |
-77.86523493732983, | |
40.802739581300834 | |
], | |
[ | |
-77.86590519416168, | |
40.801973139177605 | |
], | |
[ | |
-77.86661823334452, | |
40.802286194071826 | |
], | |
[ | |
-77.86750240193129, | |
40.80129304931923 | |
], | |
[ | |
-77.86821544111412, | |
40.80163849265777 | |
], | |
[ | |
-77.8666610156955, | |
40.803387271969775 | |
] | |
] | |
] | |
} | |
} | |
] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assaults = { | |
"type": "FeatureCollection", | |
"crs": { | |
"type": "name", | |
"properties": { | |
"name": "urn:ogc:def:crs:OGC:1.3:CRS84" | |
} | |
}, | |
"features": [ | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "East Halls", | |
"Date": "2015/01/18", | |
"IncidenNum": "PSU201500496" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86258511040822, | |
40.80641348886709 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "East Halls", | |
"Date": "2015/01/31", | |
"IncidenNum": "PSU201500497" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86231890911328, | |
40.80614003271399 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "East View Terrace", | |
"Date": "2015/02/08", | |
"IncidenNum": "PSU201500563" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85421521880036, | |
40.80155947464418 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "South Halls", | |
"Date": "2015/02/15", | |
"IncidenNum": "PSU201500667" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.8566466824138, | |
40.79901178472633 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "East Halls", | |
"Date": "2015/01/30", | |
"IncidenNum": "PSU201500776" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86228682235001, | |
40.80667614963735 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "HHD Building", | |
"Date": "2015/03/02", | |
"IncidenNum": "PSU201500914" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86146801568836, | |
40.79695700901345 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Pollock Halls", | |
"Date": "2015/04/08", | |
"IncidenNum": "PSU201501393" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.8575510537773, | |
40.80094415195623 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Katz Building", | |
"Date": "2015/04/17", | |
"IncidenNum": "PSU201501549" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86627865337542, | |
40.80735258652936 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Pollock Halls", | |
"Date": "2015/04/23", | |
"IncidenNum": "PSU201501663" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85776971912668, | |
40.80116185458071 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "East Halls", | |
"Date": "2015/03/18", | |
"IncidenNum": "PSU201501675" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86193719547067, | |
40.8064548672449 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Park Ave IM Fields", | |
"Date": "2015/05/01", | |
"IncidenNum": "PSU201501817" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86433300712498, | |
40.80926132404443 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Nittany Lion Shrine", | |
"Date": "2015/07/10", | |
"IncidenNum": "PSU201502364" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86893389246231, | |
40.79682404016078 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Pollock Halls", | |
"Date": "2015/07/12", | |
"IncidenNum": "PSU201502408" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85753477272583, | |
40.80139997726714 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Nittany Apartments", | |
"Date": "2015/07/10", | |
"IncidenNum": "PSU201502441" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85688828386674, | |
40.80279748015457 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Simmons Hall", | |
"Date": "2015/07/31", | |
"IncidenNum": "PSU201502531" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85827633347601, | |
40.79953374552104 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Sackett Building", | |
"Date": "2015/09/04", | |
"IncidenNum": "PSU201502936" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86261874209946, | |
40.79482137806847 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "West Halls", | |
"Date": "2015/09/13", | |
"IncidenNum": "PSU201503109" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86673654338038, | |
40.79620237568974 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "East Halls", | |
"Date": "2015/09/16", | |
"IncidenNum": "PSU201503177" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86275303114557, | |
40.806699717349886 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Johnston Commons - East Halls", | |
"Date": "2014/11/07", | |
"IncidenNum": "PSU201404521" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86170724034406, | |
40.80603406840759 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "West Halls", | |
"Date": "2014/10/25", | |
"IncidenNum": "PSU201404276" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86647984927461, | |
40.796336425395026 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Stone Hall - East Halls", | |
"Date": "2014/10/12", | |
"IncidenNum": "PSU201404002" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86174526910054, | |
40.807052328679 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "West College Ave near Hammond Building", | |
"Date": "2014/09/19", | |
"IncidenNum": "PSU201403444" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86215645502932, | |
40.794130418639305 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "South Halls", | |
"Date": "2014/09/06", | |
"IncidenNum": "PSU201403166" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85719330618383, | |
40.798584341644855 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "intersection of Porter and Curtin Road", | |
"Date": "2014/08/31", | |
"IncidenNum": "PSU201403026" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85410093447439, | |
40.812327362370375 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Pollock Halls", | |
"Date": "2014/08/09", | |
"IncidenNum": "none given" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85712707276645, | |
40.801216969828545 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "South Halls", | |
"Date": "2014/08/09", | |
"IncidenNum": "PSU201402715" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85705101525362, | |
40.79920976222484 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Business Building", | |
"Date": "2014/05/18", | |
"IncidenNum": "PSU201402123" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86541258807117, | |
40.80399558193616 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "McElwain Hall- South Halls", | |
"Date": "2014/05/03", | |
"IncidenNum": "PSU201401949" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.85919013280214, | |
40.80003381141421 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Nittany Apartments", | |
"Date": "2014/03/22", | |
"IncidenNum": "PSU201401179" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.8566922674148, | |
40.80307352884847 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "North Halls", | |
"Date": "2014/02/05", | |
"IncidenNum": "PSU201400486" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86714898703109, | |
40.80230799016218 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "West College Avenue, south of Hammond Building", | |
"Date": "2014/01/18", | |
"IncidenNum": "none given" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.86246372540057, | |
40.79390132681418 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Pollock Halls", | |
"Date": "2015/10/01", | |
"IncidenNum": "PSU201601459" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.8571871166078, | |
40.80156295331749 | |
] | |
} | |
}, | |
{ | |
"type": "Feature", | |
"properties": { | |
"Id": 0, | |
"Lat": 0, | |
"Long": 0, | |
"Location": "Innovation Park", | |
"Date": "2013/01/01", | |
"IncidenNum": "PSU201304083" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ | |
-77.84473050529473, | |
40.83133389908803 | |
] | |
} | |
} | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment