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

Lab week 7 #9

Open
wants to merge 1 commit 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
4 changes: 2 additions & 2 deletions labs/lab1/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ p.main {
.map {
position: absolute;
right: 0px;
left: 400px;
left: 300px;
height: 100%;
top: 0;
}

.sidebar {
position: absolute;
left: 0px;
width: 400px;
width: 300px;
top: 0;
bottom: 0;
overflow-y: auto;
Expand Down
96 changes: 24 additions & 72 deletions labs/lab1/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,97 +47,49 @@ https://medium.com/@sumit.arora/what-is-geojson-geojson-basics-visualize-geojson

// Task 1.1 - add the five markers from squares.json to the map using the methods
// we've used so far in class: _.map or _.each, forEach()

markers = squaresJson.map((point) => {
return L.marker([point.LAT, point.LNG]).addTo(map);
});

// Task 1.2 - remove squares.json from the map
// iterating over each marker using map.removeLayer(point)


// markers = squaresJson.map((point) => {
// return L.marker([point.LAT, point.LNG]).addTo(map);
// })
//
//
// markers.forEach((point) => {
// map.removeLayer(point)})



// layer.addTo(map);
// map.removeLayer(squaresPoly)


// _.forEach(squaresJson,(point) => {
// return L.marker([point.LAT, point.LNG]).addTo(map)
// });







// iterating over each marker using map.removeLayer(point)
markers.forEach((point) => {
map.removeLayer(point)
});

// task 2.1 - add squares.geojson to the map
// Try: L.geoJSON().addTo(map);

var t2 = L.geoJSON(squaresGeoJson).addTo(map);

// task 2.2 - remove squares.geojson from the map
// Try: map.removeLayer()


map.removeLayer(t2);

// task 3 - filter by some property on squares.geojson


// L.geoJSON(squaresGeoJson, {
// filter: function(feature) {
// return feature.properties.DOB_NAMESAKE == 1674;
// }
// }).addTo(map);



var t3 = L.geoJSON(squaresGeoJson, {
filter: function(feature) {
return feature.properties.DOB_NAMESAKE == 1674;
}
}).addTo(map);
map.removeLayer(t3);

// task 4.1 - add squaresPoly.geojson to the map
// task 4.2 - add conditional coloring to squaresPoly.geojson


var t4 = L.geoJSON(squaresPoly).addTo(map);

// task 4.2 - add conditional coloring to squaresPoly.geojson
t4.setStyle(function(layer) {
if (layer.properties.INDEGO_STATION === true) {
return {color: 'green', fillColor: 'yellow'};
}
});

// task 5 - add two buttons to the sidebar from javascript using jquery: (1) add layer (2) remove layer


$('<br><input type="button" id="btnToAdd" value="add" />').appendTo($(".sidebar"));

$('<br><input type="button" id="btnToRemove" value="remove" />').appendTo($(".sidebar"));


$( "#btnToAdd" ).click(function() {
layer.addTo(map);
t4.addTo(map);
});


$( "#btnToRemove" ).click(function() {
map.removeLayer(layer);
map.removeLayer(t4);
});





// var myStyle = function(feature) {
// if (feature.properties.INDEGO_STATION == true) {
// return {fillColor: 'red'};
// } else if (feature.properties.COLLDAY == "MON") {
// return {fillColor: 'green'}
// } else return {fillColor: 'yellow'}
// };


var myStyle = function(feature) {
if (feature.properties.INDEGO_STATION == true) {
console.log("trues")
return {fillColor: 'green'};
} else return {fillColor: 'red'}
};
28 changes: 25 additions & 3 deletions labs/lab2/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ p.main {
.map {
position: absolute;
right: 0px;
left: 400px;
left: 300px;
height: 100%;
top: 0;
}

.sidebar {
position: absolute;
left: 0px;
width: 400px;
width: 300px;
top: 0;
bottom: 0;
overflow-y: auto;
Expand All @@ -29,6 +29,28 @@ p.main {

.legend {
position: absolute;
background-color: #fff;
z-index: 2000;
display:table;
bottom:40px;
right:20px;
border-collapse:collapse;
font-weight:bold;
}

.legend td {padding:5px;}

.key {
width: 27px;
height: 27px;
border: 3px solid black;
border-collapse:collapse;
border-spacing:0;
opacity:0.25;
}

.close {
cursor:pointer;
float:right;
line-height:37px;
width:37px;
}
Loading