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

HW3 submission #24

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
Binary file added SagariDatta_HW3/lab1/images/layers-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SagariDatta_HW3/lab1/images/layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SagariDatta_HW3/lab1/images/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SagariDatta_HW3/lab1/images/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SagariDatta_HW3/lab1/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
479 changes: 479 additions & 0 deletions SagariDatta_HW3/lab1/leaflet.css

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions SagariDatta_HW3/lab1/leaflet.js

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions SagariDatta_HW3/lab1/part1-array-access.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html>
<head>
<!--stylesheet imports-->
<link rel="stylesheet" href="leaflet.css" />
</head>
<body>

<!--left panel-->
<div style="position: absolute; left: 0px; width: 400px; top: 0; bottom: 0;"></div>
<!--map-->
<div id="map" style="position: absolute; right: 0; left: 400px; top: 0; bottom: 0;"></div>

<!--javascript imports-->
<script src="leaflet.js"></script>

<script>

/* =====================

# Lab 1, Part 1 — Array Access

## Introduction

Refactor your week 1 homework assignment to leverage some of the Javascript
functionality we have been learning about. We will start by improving the
way we store data and the amount of times we call the L.marker method.

## Task 1: Data Storage

Let's consider a marker for a single restaurant point location. We could
store information about that marker as an array
([element1, element2, element3...]). Your point location array should
contain the following three elements in this order: 1. lat, 2. lng, 3. label.

Create an array of arrays (an array that contains multiple arrays) to
represent every restaurant in your restaurant data. Save this as variable
"restaurantData".

## Task 2: Process Data

Create a marker for each element in "restaurantData". Your final code should
only include "L.marker" one time.

## Task 3: Add Two Additional Markers

Add two additional restaurants to your data. You should only need to modify
"restaurantData" to do this. Confirm that these new markers are added to
your application.

## Task 4: Add Popups to Markers

Add popups to your markers. The popup should contain the label for your
restaurant. Refer to the Leaflet documentation for instructions on adding
a popup: http://leafletjs.com/reference.html#popup

===================== */

var map = L.map('map', {
center: [39.9522, -75.1639],
zoom: 14
});

var Stamen_TonerLite = L.tileLayer('http://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.{ext}', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20,
ext: 'png'
}).addTo(map);

/* =====================

Start code

===================== */

//Create arrays
restaurantData = [ [39.955032, -75.202487, "Han Dynasty"], [39.956887, -75.196624, "U-Town"], [39.953096, -75.192071, "Food Mart"], [39.957512, -75.191771, "Blaze Pizza"], [39.953861, -75.187737, "Shake Shack"]]

//Add marker
//console.log(restaurantData.length); //checking array length
for (var i=0; i < restaurantData.length; i = i+1) {
//checking array values
//console.log(restaurantData[i]);
//console.log(restaurantData[i][i]);
L.marker([restaurantData[i][0], restaurantData[i][1]]).addTo(map).bindPopup(data1[i][2]).openPopup();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data1 is not defined and it's throwing an error. When set to restaurantData it works.

}


/* =====================

End code

===================== */

</script>
</body>
</html>
53 changes: 53 additions & 0 deletions SagariDatta_HW3/lab1/part2-fizzbuzz.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>

<script>

/* =====================

# Lab 1, Part 2 — FizzBuzz

## Introduction

Write a program that uses console.log to print the numbers from 1 to 100.
For multiples of three, print "Fizz" instead of the number. For multiples
of five, print "Buzz" instead of the number. For numbers which are multiples
of both three and five, print "FizzBuzz".

Believe it or not, this is a common programming challenge in job interviews.

===================== */

/* =====================

Start code

===================== */

for (var i = 0; i < 101; i++){
if ((i % 3 == 0) && (i % 5 == 0)) {
console.log(i);
console.log("FrizzBuzz")
}
else if (i% 3 == 0) {
console.log(i);
console.log("Frizz");
}
else if (i % 5 == 0) {
console.log(i);
console.log("Buzz");
}
}

/* =====================

End code

===================== */

</script>
</body>
</html>
Loading