-
Notifications
You must be signed in to change notification settings - Fork 30
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
Yufei Yuan-Assignment 4 #15
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ to true. | |
===================== */ | ||
|
||
var query1; | ||
|
||
query1 = _.isFunction(printMenu); | ||
console.log('printMenu is a function:', query1); | ||
|
||
/* ===================== | ||
|
@@ -73,7 +73,7 @@ to true. | |
===================== */ | ||
|
||
var query2; | ||
|
||
query2 = _.isArray(bakedGoods); | ||
console.log('bakedGoods is an array:', query2); | ||
|
||
/* ===================== | ||
|
@@ -82,39 +82,39 @@ underscore. Should evaluate to true. | |
===================== */ | ||
|
||
var query3; | ||
|
||
query3 = _isObject(_.first(bakedGoods)); | ||
console.log('The first element in bakedGoods is an object:', query3); | ||
|
||
/* ===================== | ||
Use _.where to return all cakes. Or bread. Whichever is your favorite. | ||
===================== */ | ||
|
||
var query4; | ||
|
||
query4 = _.where(bakedGoods, {type:'Cake'}); | ||
console.log('All bread. Or cakes:', query4); | ||
|
||
/* ===================== | ||
Use _.filter to return all baked goods that cost more than $4. | ||
===================== */ | ||
|
||
var query5; | ||
|
||
query5 = ._filter(bakedGoods, function(obj) {return obj.price>4;}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. order is important with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
console.log('More than $4:', query5); | ||
|
||
/* ===================== | ||
Use _.sortBy to order the list by inventory (from lowest to highest). | ||
===================== */ | ||
|
||
var query6; | ||
|
||
query6 = _.sortBy(bakedGoods, bakedGoods, 'inventory'); | ||
console.log('Sorted by inventory (lowest to highest):', query6); | ||
|
||
/* ===================== | ||
Use _.groupBy to organize the baked goods by type. | ||
===================== */ | ||
|
||
var query7; | ||
|
||
query7 = _.groupBy(bakedGoods, 'type'); | ||
console.log('Grouped by type:', query7); | ||
|
||
/* ===================== | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* ===================== | ||
/* ===================== | ||
Lab 2, part 2 - application state | ||
|
||
Spatial applications aren't typically as simple as putting data on a map. In | ||
|
@@ -34,10 +34,17 @@ | |
===================== */ | ||
|
||
// We set this to HTTP to prevent 'CORS' issues | ||
var downloadData = $.ajax("http://"); | ||
var parseData = function() {}; | ||
var makeMarkers = function() {}; | ||
var plotMarkers = function() {}; | ||
var downloadData = $.ajax("datasets/geojson/HousingCounselingAgencies.geojson"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where and what is this dataset? Does it work for you? i get an error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work now. |
||
var parseData = function(data) { | ||
return JSON.parse(data); | ||
}; | ||
var makeAMarker = function(list) { | ||
var listOfMarkers=[]; | ||
_.each(list, function(obj){listOfMarkers.push(L.marker([obj.Lat, obj.Lng]));}); | ||
return listOfMarkers; | ||
}; | ||
var plotMarkers = function(list) {_.each(list, function(obj){obj.addTo(map);}); | ||
}; | ||
|
||
|
||
/* ===================== | ||
|
@@ -53,7 +60,7 @@ var plotMarkers = function() {}; | |
user's input. | ||
===================== */ | ||
|
||
var removeMarkers = function() {}; | ||
var removeMarkers = function(list) {_.each(list, function(obj){map.removeLayer(obj);});}; | ||
|
||
/* ===================== | ||
Optional, stretch goal | ||
|
@@ -85,7 +92,8 @@ var Stamen_TonerLite = L.tileLayer('http://stamen-tiles-{s}.a.ssl.fastly.net/ton | |
|
||
downloadData.done(function(data) { | ||
var parsed = parseData(data); | ||
var markers = makeMarkers(parsed); | ||
var markers = makeAMarker(parsed); | ||
var markersFilter = function(listNotFiltered){_.filter(listNotFiltered, function(a){return a.HOUSE<2000;});}; | ||
plotMarkers(markers); | ||
removeMarkers(markers); | ||
removeMarkers(markersFilter(markers)); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont forget that
.
with underscoreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed