Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Lufeng-Week9” #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Week 9

LINK: https://lufenglin.github.io/
*As always: make a copy of this repository to commit changes to*

## Class Outline
Expand Down
9 changes: 9 additions & 0 deletions css/reset.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
body {
padding: 0;
overflow: hidden;
font-family: colfax, helvetica, arial, sans-serif;
}

p.main {
text-align: justify;
font-size: 16px;
}

.slide {
font-size: 14px;
}

.map {
position: absolute;
right: 0px;
left: 38.2%;
height: 100%;
top: 0;
}

.sidebar {
background-color: #EDEDED;
position: absolute;
left: 0px;
width: 38.2%;
top: 0;
bottom: 0;
overflow-y: auto;
padding: 20px;
font-size: 16px;
text-align: justify;

}

.legend {
background-color: #fff;
z-index: 2000;
line-height: 20px;
color: #555;
width:120px;
height:180px;
padding: 6px 8px;
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}

.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
}

.button {
background-color: #CCCACA; /* Green */
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
font-size: 20px;
}
#next {float:right;}
#previous {float:left;visibility:hidden;}
51 changes: 51 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- CSS Imports -->
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.4.0/leaflet.css" integrity="sha256-YR4HrDE479EpYZgeTkQfgVJq08+277UXxMLbi/YP69o=" crossorigin="anonymous" />
<link rel="stylesheet" href="css/style.css" />
</head>
<head>
<div class="sidebar">
<div id="intro">
<h2>Philadelphia</h2>
<p class="main" id="welcomepage">Philadelphia, sometimes known colloquially as Philly,
is the largest city in the U.S. state and Commonwealth of Pennsylvania, and the
sixth-most populous U.S. city, with a 2017 census-estimated population of 1,580,863.
Since 1854, the city has been coterminous with Philadelphia County, the most populous
county in Pennsylvania and the urban core of the eighth-largest U.S. metropolitan
statistical area, with over 6 million residents as of 2017.</p>
<div style="clear:both"></div>
</div>
</div>
</head>
<head>
<meta charset='utf-8' />
<title>Display a map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; left: 38%;width:80%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoibHVmZW5nbGluIiwiYSI6ImNqcGE0eWdxdTFtZmUzcHFzcTV6OW40cHIifQ.JZFzns7G90tC3m6AgYzi7w';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v11', // stylesheet location
center: [-75.08, 39.97], // starting position [lng, lat]
zoom: 11 // starting zoom
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.4.0/leaflet.js" integrity="sha256-6BZRSENq3kxI4YYBDqJ23xg0r1GwTHEpvp3okdaIqBw=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore.js" integrity="sha256-O4179En8zabOlPYBNvGp8cF0uh0vnSZpW4Q6Ul1h+8c=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="js/main.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var phillyCrimeDataUrl = "https://raw.githubusercontent.com/CPLN692-MUSA611/datasets/master/json/philadelphia-crime-snippet.json";
var crimedata;

// async ajax call
var getCrimeData = function() {
$.ajax(phillyCrimeDataUrl).done(function(ajaxResponseValue) {
crimedata = JSON.parse(ajaxResponseValue);
console.log(crimedata);
_.forEach(crimedata, function(x){
L.marker([x.Lat, x.Lng]).addTo(map);
});
});
};


// run the ajax function
getCrimeData();