├── 01-base
├── css
│ ├── style.css
│ └── lib
│ │ └── leaflet-0.75.css
├── js
│ ├── script.js
│ └── lib
│ │ ├── images
│ │ ├── layers.png
│ │ ├── zoom-in.png
│ │ ├── zoom-out.png
│ │ ├── layers-2x.png
│ │ ├── marker-icon.png
│ │ ├── marker-icon2x.png
│ │ ├── marker-shadow.png
│ │ └── marker-icon-2x.png
│ │ └── tile.stamen-1.3.0.js
├── index.html
├── csv
│ ├── population.csv
│ └── ia-breweries.csv
└── json
│ ├── ia-breweries.json
│ └── ia-counties.geojson
├── 02-final
├── css
│ ├── style.css
│ └── lib
│ │ └── leaflet-0.75.css
├── js
│ ├── lib
│ │ ├── images
│ │ │ ├── layers.png
│ │ │ ├── zoom-in.png
│ │ │ ├── layers-2x.png
│ │ │ ├── zoom-out.png
│ │ │ ├── marker-icon.png
│ │ │ ├── marker-icon-2x.png
│ │ │ ├── marker-icon2x.png
│ │ │ └── marker-shadow.png
│ │ └── tile.stamen-1.3.0.js
│ └── script.js
├── index.html
├── csv
│ ├── population.csv
│ └── ia-breweries.csv
└── json
│ └── ia-breweries.json
├── imgs
├── 01.png
├── 02.png
├── 03.png
├── 04.png
├── 05.png
└── 06.png
├── about.md
└── readme.md
/01-base/css/style.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/01-base/js/script.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/02-final/css/style.css:
--------------------------------------------------------------------------------
1 | #map {
2 | width: 100%;
3 | height: 500px;
4 | }
--------------------------------------------------------------------------------
/imgs/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/imgs/01.png
--------------------------------------------------------------------------------
/imgs/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/imgs/02.png
--------------------------------------------------------------------------------
/imgs/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/imgs/03.png
--------------------------------------------------------------------------------
/imgs/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/imgs/04.png
--------------------------------------------------------------------------------
/imgs/05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/imgs/05.png
--------------------------------------------------------------------------------
/imgs/06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/imgs/06.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/layers.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/zoom-in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/zoom-in.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/zoom-out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/zoom-out.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/layers.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/zoom-in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/zoom-in.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/layers-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/layers-2x.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/marker-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/marker-icon.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/layers-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/layers-2x.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/zoom-out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/zoom-out.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/marker-icon2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/marker-icon2x.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/marker-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/marker-shadow.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/marker-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/marker-icon.png
--------------------------------------------------------------------------------
/01-base/js/lib/images/marker-icon-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/01-base/js/lib/images/marker-icon-2x.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/marker-icon-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/marker-icon-2x.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/marker-icon2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/marker-icon2x.png
--------------------------------------------------------------------------------
/02-final/js/lib/images/marker-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/csessig86/leaflet-maps-intro/HEAD/02-final/js/lib/images/marker-shadow.png
--------------------------------------------------------------------------------
/about.md:
--------------------------------------------------------------------------------
1 | #Building maps with Leaflet.js
2 | * NICAR 2016
3 | * Friday, March 11 at 11:30 a.m.
4 | * [More information](http://www.ire.org/events-and-training/event/2198/2256/)
5 |
6 | ###Course description
7 |
8 | * Maps! Who doesn't love wonderful, colorful maps? In this course we will be building a map with Leaflet.js., a very popular Javascript mapping library. The map will display both markers and shapes. The shapes will be used to create a basic choropleth map.
9 |
10 | * I suggest participants have a beginner's knowledge of Javascript. It would be helpful if you are familiar with basic Javascript concepts like objects, arrays and for loops. We will also be working with JSON and GeoJSON data. Some knowledge of these would be also helpful.
11 |
12 | ###About the author
13 | * Chris Essig is a web developer at The Gazette in Cedar Rapids, Iowa.
14 | * [@CEssig](https://twitter.com/cessig)
15 | * csessig86@gmail.com
--------------------------------------------------------------------------------
/01-base/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Intro to Leaflet
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/02-final/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Intro to Leaflet
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/02-final/js/script.js:
--------------------------------------------------------------------------------
1 | // Call Stamen tiles
2 | var layer = new L.StamenTileLayer('toner-background');
3 |
4 | // Initialize our map
5 | // The first setview parameter is the lat, long
6 | // Of the initial zoom
7 | // The second parameter is the zoom level
8 | var map = new L.Map('map').setView([42,-93],7);
9 | map.addLayer(layer);
10 |
11 | // Set the color of the individual county
12 | // All colors are shades of green
13 | // The more population, the darker the county will appear on the map
14 | function setColor(population) {
15 | var population_num = parseInt(population)
16 |
17 | if (population_num > 150000) {
18 | return '#005824';
19 | } else if (population_num > 125000) {
20 | return '#238b45';
21 | } else if (population_num > 100000) {
22 | return '#41ae76';
23 | } else if (population_num > 75000) {
24 | return '#66c2a4';
25 | } else if (population_num > 50000) {
26 | return '#99d8c9';
27 | } else if (population_num > 25000) {
28 | return '#ccece6';
29 | } else {
30 | return '#edf8fb';
31 | }
32 | }
33 |
34 | // Styles for each county on the map
35 | // With this, we grab each county's population
36 | // And send it to the setColor function above
37 | function setStyle(feature) {
38 | return {
39 | opacity: 1,
40 | weight: 2,
41 | color: "#FFF",
42 | fillColor: setColor(feature.properties.population),
43 | fillOpacity: 0.8
44 | }
45 | }
46 |
47 | // Call the GeoJSON file ia-counties
48 | // Which is in a variable called iowa_counties
49 | // And add to the map
50 | L.geoJson(iowa_counties, {
51 | style: setStyle
52 | }).addTo(map);
53 |
54 | // Loop through each brewery in our breweries variable
55 | // Each brewery is an object
56 | // Inside breweries, which is an array
57 | for (var num = 0; num < breweries.length; num++) {
58 | // Grab information on the brewery we are currently looping through
59 | var brewery = breweries[num];
60 | var brewery_lat = brewery["latitude"];
61 | var brewery_long = brewery["longitude"];
62 | var brewery_name = brewery["brewery"];
63 | var brewery_address = brewery["address"];
64 | var brewery_city = brewery["city"];
65 |
66 | // Use Leaflet to add a marker for each brewery
67 | // And give it the lat, long information
68 | // In the current brewery's object
69 | var marker = L.marker([brewery_lat, brewery_long]).addTo(map);
70 |
71 | // HTML that will appear in popup
72 | var popup_html = '
' + brewery_name + '
';
73 | popup_html += '
' + brewery_address + '
';
74 | popup_html += '
' + brewery_city + '
'
75 |
76 | // Bind the popup to the marker using Leaflet
77 | marker.bindPopup(popup_html);
78 | }
--------------------------------------------------------------------------------
/01-base/csv/population.csv:
--------------------------------------------------------------------------------
1 | geoid,name,population
05000US19001,"Adair County, IA",7543
05000US19003,"Adams County, IA",3937
05000US19005,"Allamakee County, IA",14152
05000US19007,"Appanoose County, IA",12754
05000US19009,"Audubon County, IA",5935
05000US19011,"Benton County, IA",25895
05000US19013,"Black Hawk County, IA",131947
05000US19015,"Boone County, IA",26326
05000US19017,"Bremer County, IA",24481
05000US19019,"Buchanan County, IA",20947
05000US19021,"Buena Vista County, IA",20460
05000US19023,"Butler County, IA",14966
05000US19025,"Calhoun County, IA",9980
05000US19027,"Carroll County, IA",20702
05000US19029,"Cass County, IA",13694
05000US19031,"Cedar County, IA",18434
05000US19033,"Cerro Gordo County, IA",43707
05000US19035,"Cherokee County, IA",11982
05000US19037,"Chickasaw County, IA",12329
05000US19039,"Clarke County, IA",9284
05000US19041,"Clay County, IA",16555
05000US19043,"Clayton County, IA",17900
05000US19045,"Clinton County, IA",48663
05000US19047,"Crawford County, IA",17259
05000US19049,"Dallas County, IA",72124
05000US19051,"Davis County, IA",8765
05000US19053,"Decatur County, IA",8286
05000US19055,"Delaware County, IA",17578
05000US19057,"Des Moines County, IA",40265
05000US19059,"Dickinson County, IA",16877
05000US19061,"Dubuque County, IA",95166
05000US19063,"Emmet County, IA",10068
05000US19065,"Fayette County, IA",20693
05000US19067,"Floyd County, IA",16153
05000US19069,"Franklin County, IA",10572
05000US19071,"Fremont County, IA",7200
05000US19073,"Greene County, IA",9232
05000US19075,"Grundy County, IA",12403
05000US19077,"Guthrie County, IA",10794
05000US19079,"Hamilton County, IA",15363
05000US19081,"Hancock County, IA",11175
05000US19083,"Hardin County, IA",17406
05000US19085,"Harrison County, IA",14600
05000US19087,"Henry County, IA",20197
05000US19089,"Howard County, IA",9529
05000US19091,"Humboldt County, IA",9731
05000US19093,"Ida County, IA",7085
05000US19095,"Iowa County, IA",16316
05000US19097,"Jackson County, IA",19656
05000US19099,"Jasper County, IA",36715
05000US19101,"Jefferson County, IA",17102
05000US19103,"Johnson County, IA",136802
05000US19105,"Jones County, IA",20607
05000US19107,"Keokuk County, IA",10361
05000US19109,"Kossuth County, IA",15347
05000US19111,"Lee County, IA",35552
05000US19113,"Linn County, IA",214927
05000US19115,"Louisa County, IA",11305
05000US19117,"Lucas County, IA",8785
05000US19119,"Lyon County, IA",11680
05000US19121,"Madison County, IA",15629
05000US19123,"Mahaska County, IA",22420
05000US19125,"Marion County, IA",33308
05000US19127,"Marshall County, IA",40922
05000US19129,"Mills County, IA",14946
05000US19131,"Mitchell County, IA",10744
05000US19133,"Monona County, IA",9149
05000US19135,"Monroe County, IA",8019
05000US19137,"Montgomery County, IA",10549
05000US19139,"Muscatine County, IA",42857
05000US19141,"O'Brien County, IA",14173
05000US19143,"Osceola County, IA",6279
05000US19145,"Page County, IA",15737
05000US19147,"Palo Alto County, IA",9263
05000US19149,"Plymouth County, IA",24899
05000US19151,"Pocahontas County, IA",7191
05000US19153,"Polk County, IA",445136
05000US19155,"Pottawattamie County, IA",93153
05000US19157,"Poweshiek County, IA",18765
05000US19159,"Ringgold County, IA",5082
05000US19161,"Sac County, IA",10162
05000US19163,"Scott County, IA",168714
05000US19165,"Shelby County, IA",12034
05000US19167,"Sioux County, IA",34261
05000US19169,"Story County, IA",91939
05000US19171,"Tama County, IA",17568
05000US19173,"Taylor County, IA",6225
05000US19175,"Union County, IA",12554
05000US19177,"Van Buren County, IA",7487
05000US19179,"Wapello County, IA",35406
05000US19181,"Warren County, IA",47058
05000US19183,"Washington County, IA",21906
05000US19185,"Wayne County, IA",6385
05000US19187,"Webster County, IA",37399
05000US19189,"Winnebago County, IA",10645
05000US19191,"Winneshiek County, IA",20957
05000US19193,"Woodbury County, IA",102372
05000US19195,"Worth County, IA",7567
05000US19197,"Wright County, IA",13007
--------------------------------------------------------------------------------
/02-final/csv/population.csv:
--------------------------------------------------------------------------------
1 | geoid,name,population
05000US19001,"Adair County, IA",7543
05000US19003,"Adams County, IA",3937
05000US19005,"Allamakee County, IA",14152
05000US19007,"Appanoose County, IA",12754
05000US19009,"Audubon County, IA",5935
05000US19011,"Benton County, IA",25895
05000US19013,"Black Hawk County, IA",131947
05000US19015,"Boone County, IA",26326
05000US19017,"Bremer County, IA",24481
05000US19019,"Buchanan County, IA",20947
05000US19021,"Buena Vista County, IA",20460
05000US19023,"Butler County, IA",14966
05000US19025,"Calhoun County, IA",9980
05000US19027,"Carroll County, IA",20702
05000US19029,"Cass County, IA",13694
05000US19031,"Cedar County, IA",18434
05000US19033,"Cerro Gordo County, IA",43707
05000US19035,"Cherokee County, IA",11982
05000US19037,"Chickasaw County, IA",12329
05000US19039,"Clarke County, IA",9284
05000US19041,"Clay County, IA",16555
05000US19043,"Clayton County, IA",17900
05000US19045,"Clinton County, IA",48663
05000US19047,"Crawford County, IA",17259
05000US19049,"Dallas County, IA",72124
05000US19051,"Davis County, IA",8765
05000US19053,"Decatur County, IA",8286
05000US19055,"Delaware County, IA",17578
05000US19057,"Des Moines County, IA",40265
05000US19059,"Dickinson County, IA",16877
05000US19061,"Dubuque County, IA",95166
05000US19063,"Emmet County, IA",10068
05000US19065,"Fayette County, IA",20693
05000US19067,"Floyd County, IA",16153
05000US19069,"Franklin County, IA",10572
05000US19071,"Fremont County, IA",7200
05000US19073,"Greene County, IA",9232
05000US19075,"Grundy County, IA",12403
05000US19077,"Guthrie County, IA",10794
05000US19079,"Hamilton County, IA",15363
05000US19081,"Hancock County, IA",11175
05000US19083,"Hardin County, IA",17406
05000US19085,"Harrison County, IA",14600
05000US19087,"Henry County, IA",20197
05000US19089,"Howard County, IA",9529
05000US19091,"Humboldt County, IA",9731
05000US19093,"Ida County, IA",7085
05000US19095,"Iowa County, IA",16316
05000US19097,"Jackson County, IA",19656
05000US19099,"Jasper County, IA",36715
05000US19101,"Jefferson County, IA",17102
05000US19103,"Johnson County, IA",136802
05000US19105,"Jones County, IA",20607
05000US19107,"Keokuk County, IA",10361
05000US19109,"Kossuth County, IA",15347
05000US19111,"Lee County, IA",35552
05000US19113,"Linn County, IA",214927
05000US19115,"Louisa County, IA",11305
05000US19117,"Lucas County, IA",8785
05000US19119,"Lyon County, IA",11680
05000US19121,"Madison County, IA",15629
05000US19123,"Mahaska County, IA",22420
05000US19125,"Marion County, IA",33308
05000US19127,"Marshall County, IA",40922
05000US19129,"Mills County, IA",14946
05000US19131,"Mitchell County, IA",10744
05000US19133,"Monona County, IA",9149
05000US19135,"Monroe County, IA",8019
05000US19137,"Montgomery County, IA",10549
05000US19139,"Muscatine County, IA",42857
05000US19141,"O'Brien County, IA",14173
05000US19143,"Osceola County, IA",6279
05000US19145,"Page County, IA",15737
05000US19147,"Palo Alto County, IA",9263
05000US19149,"Plymouth County, IA",24899
05000US19151,"Pocahontas County, IA",7191
05000US19153,"Polk County, IA",445136
05000US19155,"Pottawattamie County, IA",93153
05000US19157,"Poweshiek County, IA",18765
05000US19159,"Ringgold County, IA",5082
05000US19161,"Sac County, IA",10162
05000US19163,"Scott County, IA",168714
05000US19165,"Shelby County, IA",12034
05000US19167,"Sioux County, IA",34261
05000US19169,"Story County, IA",91939
05000US19171,"Tama County, IA",17568
05000US19173,"Taylor County, IA",6225
05000US19175,"Union County, IA",12554
05000US19177,"Van Buren County, IA",7487
05000US19179,"Wapello County, IA",35406
05000US19181,"Warren County, IA",47058
05000US19183,"Washington County, IA",21906
05000US19185,"Wayne County, IA",6385
05000US19187,"Webster County, IA",37399
05000US19189,"Winnebago County, IA",10645
05000US19191,"Winneshiek County, IA",20957
05000US19193,"Woodbury County, IA",102372
05000US19195,"Worth County, IA",7567
05000US19197,"Wright County, IA",13007
--------------------------------------------------------------------------------
/01-base/csv/ia-breweries.csv:
--------------------------------------------------------------------------------
1 | brewery,address,city,phone,website,latitude,longitude
2 | 515 Brewing Company,7700 University Ave.,"Clive, IA 50325",(515) 661-4615,www.515brewing.com,41.600002,-93.722766
3 | Angry Cedar Brewing Company,"730 Technology Place
4 | ","Waverly, IA, 50677",NA,www.angrycedar.com,42.726667,-92.475278
5 | Appanoose Rapids Brewing Company,332 East Main Street,"Ottumwa, IA, 52501",(641) 684-4008,www.appanooserapidsbrewingcompany.com,41.015936,-92.410008
6 | Backpocket Brewing Company,903 Quarry Road,"Coralville, IA 52241",(319) 466-4444,www.backpocketbrewing.com,41.681596,-91.559932
7 | Beck’s Sports Brewery,3295 University Ave,"Waterloo, IA 50701",(319) 234-4333,www.barmuda.com/becks,42.500706,-92.38998
8 | "Boone Valley Brewing Company
9 | ",816 7th Street,"Boone, Iowa 50036",(515) 432-1232,NA,42.062616,-93.880685
10 | Briar Creek Brewery,NA,"Janesville, IA 50647",NA,www.briarcreekbrewery.com,42.627377,-92.46536
11 | C.I.B. (Chefs in Black) Brewery,39036 Aspen Road,"Macedonia, IA 51549",(515) 450-2981,www.cibbrewery.com,41.175571,-95.441562
12 | Confluence Brewing Company,"1235 Thomas Beck Rd., Suite A","Des Moines, IA 50315",(515) 285-9005,NA,41.568638,-93.631768
13 | Court Avenue Brewing Company,309 Court Ave,"Des Moines, IA 50309",(515) 282-2739,www.courtavebrew.com,41.585502,-93.620998
14 | Depot Deli Restaurant,101 North Railroad Street,"Shenandoah, IA 51601",(712) 246-4444,www.depotdeli.com,40.76499,-95.376992
15 | Exile Brewing Company,1514 Walnut Street,"Des Moines, IA 50309",(515) 883-2337,NA,41.583013,-93.637015
16 | Front Street Brewery,208 E. River Rd.,"Davenport, IA 52801",(319) 322-1569,www.frontstreetbrew.com,41.520357,-90.572245
17 | Granite City Food & Brewery – Worthouse,1722 Detroit Street,"Ellsworth, IA 50075",(515) 836-4060,www.gcfb.net,42.3141,-93.57481
18 | Granite City Food & Brewery – Cedar Rapids,4755 First Avenue SE,"Cedar Rapids, IA 52403",(319) 395-7500,www.gcfb.net/locations/loc_cedarrapids.cfm,42.025158,-91.621528
19 | Granite City Food & Brewery – Clive,12801 University Ave,"Clive, IA 50325",(515) 224-1300,www.gcfb.net/locations/loc_clive.cfm,41.600851,-93.79458
20 | Granite City Food & Brewery – Davenport,5280 Utica Ridge Rd,"Davenport, IA 52807",(563) 344-9700,www.gcfb.net/locations/loc_davenport.cfm,41.574625,-90.513509
21 | Great River Brewery,332 East 2nd Street,"Davenport, IA 52801",(319) 541-5160,www.greatriverbrewery.com,41.521383,-90.570087
22 | Keg Creek Brewing Company,"111 Sharp Street, PO Box 281","Glenwood, IA 51534",(712) 520-9029,www.kegcreekbrewing.com,41.047742,-95.734534
23 | Lost Duck,723 Avenue H,"Fort Madison, IA 52627",(319) 372-8255,www.duckbrewing.com,40.630008,-91.310758
24 | "Madhouse Brewing Company
25 | ","403 W. 4th St. N.
26 | ","Newton, IA 50208",(641) 831-3392,www.madhousebeer.com,41.702683,-93.060109
27 | Millstream Brewing Company,835 48th Ave,"Amana, IA 52203",(319) 622-3672,www.millstreambrewing.com,41.797214,-91.865153
28 | Number 7 Brewing,"302 SW Maple St.
29 | ","Ankeny, IA 50023",NA,NA,41.729437,-93.60883
30 | Old Man River Restaurant and Brewery,123 A. St.,"McGregor, IA 52157",(563) 873-1999,www.oldmanriverbrewery.com,43.024687,-91.174673
31 | Olde Main Brewing Co.,316 Main Street,"Ames, IA 50010",(515) 232-0553,www.oldemainbrewing.com,42.024803,-93.614693
32 | Peace Tree Brewing Company,107 West Main Street,"Knoxville, Iowa 50138",(641) 842-2739,www.peacetreebrewing.com,41.318956,-93.09892
33 | Raccoon River Brewing Company,200 Tenth Street,"Des Moines, IA 50309",(515) 362-5222,www.raccoonbrew.com,41.584066,-93.629609
34 | Rock Bottom Brewery,4508 University Ave,"West Des Moines, IA 50266",(515) 267-8900,www.rockbottom.com,41.600368,-93.789561
35 | Sutliff Cider Company,382 Sutliff Rd,"Lisbon, IA 52253",(319) 455-4093,www.sutliffcider.com,41.884377,-91.386917
36 | Third Base Brewery,500 Blairs Ferry Road NE,"Cedar Rapids, IA 52402",(319) 378-9090,www.thirdbasebrewery.com,42.035095,-91.639674
37 | Toppling Goliath Brewing Company,310 College Drive,"Decorah, IA 52101",(563) 387-6700,www.tgbrews.com,43.308374,-91.797114
38 | Twisted Wine Brewery,3021 St Charles Road,"Saint Charles, IA 50240",NA,www.twistedvinebrewery.com,41.290292,-93.800555
39 | Van Houzen Brewing Company,6602 Ginger Avenue,"Newton, IAᅠ 50208",(319) 594-9684,NA,41.680283,-93.05762
40 | Worth Brewing Company,826 Central Ave,"Northwood, IA 50459",(641) 324-9899,www.worthbrewing.com,43.444065,-93.220261
--------------------------------------------------------------------------------
/02-final/csv/ia-breweries.csv:
--------------------------------------------------------------------------------
1 | brewery,address,city,phone,website,latitude,longitude
2 | 515 Brewing Company,7700 University Ave.,"Clive, IA 50325",(515) 661-4615,www.515brewing.com,41.600002,-93.722766
3 | Angry Cedar Brewing Company,"730 Technology Place
4 | ","Waverly, IA, 50677",NA,www.angrycedar.com,42.726667,-92.475278
5 | Appanoose Rapids Brewing Company,332 East Main Street,"Ottumwa, IA, 52501",(641) 684-4008,www.appanooserapidsbrewingcompany.com,41.015936,-92.410008
6 | Backpocket Brewing Company,903 Quarry Road,"Coralville, IA 52241",(319) 466-4444,www.backpocketbrewing.com,41.681596,-91.559932
7 | Beck’s Sports Brewery,3295 University Ave,"Waterloo, IA 50701",(319) 234-4333,www.barmuda.com/becks,42.500706,-92.38998
8 | "Boone Valley Brewing Company
9 | ",816 7th Street,"Boone, Iowa 50036",(515) 432-1232,NA,42.062616,-93.880685
10 | Briar Creek Brewery,NA,"Janesville, IA 50647",NA,www.briarcreekbrewery.com,42.627377,-92.46536
11 | C.I.B. (Chefs in Black) Brewery,39036 Aspen Road,"Macedonia, IA 51549",(515) 450-2981,www.cibbrewery.com,41.175571,-95.441562
12 | Confluence Brewing Company,"1235 Thomas Beck Rd., Suite A","Des Moines, IA 50315",(515) 285-9005,NA,41.568638,-93.631768
13 | Court Avenue Brewing Company,309 Court Ave,"Des Moines, IA 50309",(515) 282-2739,www.courtavebrew.com,41.585502,-93.620998
14 | Depot Deli Restaurant,101 North Railroad Street,"Shenandoah, IA 51601",(712) 246-4444,www.depotdeli.com,40.76499,-95.376992
15 | Exile Brewing Company,1514 Walnut Street,"Des Moines, IA 50309",(515) 883-2337,NA,41.583013,-93.637015
16 | Front Street Brewery,208 E. River Rd.,"Davenport, IA 52801",(319) 322-1569,www.frontstreetbrew.com,41.520357,-90.572245
17 | Granite City Food & Brewery – Worthouse,1722 Detroit Street,"Ellsworth, IA 50075",(515) 836-4060,www.gcfb.net,42.3141,-93.57481
18 | Granite City Food & Brewery – Cedar Rapids,4755 First Avenue SE,"Cedar Rapids, IA 52403",(319) 395-7500,www.gcfb.net/locations/loc_cedarrapids.cfm,42.025158,-91.621528
19 | Granite City Food & Brewery – Clive,12801 University Ave,"Clive, IA 50325",(515) 224-1300,www.gcfb.net/locations/loc_clive.cfm,41.600851,-93.79458
20 | Granite City Food & Brewery – Davenport,5280 Utica Ridge Rd,"Davenport, IA 52807",(563) 344-9700,www.gcfb.net/locations/loc_davenport.cfm,41.574625,-90.513509
21 | Great River Brewery,332 East 2nd Street,"Davenport, IA 52801",(319) 541-5160,www.greatriverbrewery.com,41.521383,-90.570087
22 | Keg Creek Brewing Company,"111 Sharp Street, PO Box 281","Glenwood, IA 51534",(712) 520-9029,www.kegcreekbrewing.com,41.047742,-95.734534
23 | Lost Duck,723 Avenue H,"Fort Madison, IA 52627",(319) 372-8255,www.duckbrewing.com,40.630008,-91.310758
24 | "Madhouse Brewing Company
25 | ","403 W. 4th St. N.
26 | ","Newton, IA 50208",(641) 831-3392,www.madhousebeer.com,41.702683,-93.060109
27 | Millstream Brewing Company,835 48th Ave,"Amana, IA 52203",(319) 622-3672,www.millstreambrewing.com,41.797214,-91.865153
28 | Number 7 Brewing,"302 SW Maple St.
29 | ","Ankeny, IA 50023",NA,NA,41.729437,-93.60883
30 | Old Man River Restaurant and Brewery,123 A. St.,"McGregor, IA 52157",(563) 873-1999,www.oldmanriverbrewery.com,43.024687,-91.174673
31 | Olde Main Brewing Co.,316 Main Street,"Ames, IA 50010",(515) 232-0553,www.oldemainbrewing.com,42.024803,-93.614693
32 | Peace Tree Brewing Company,107 West Main Street,"Knoxville, Iowa 50138",(641) 842-2739,www.peacetreebrewing.com,41.318956,-93.09892
33 | Raccoon River Brewing Company,200 Tenth Street,"Des Moines, IA 50309",(515) 362-5222,www.raccoonbrew.com,41.584066,-93.629609
34 | Rock Bottom Brewery,4508 University Ave,"West Des Moines, IA 50266",(515) 267-8900,www.rockbottom.com,41.600368,-93.789561
35 | Sutliff Cider Company,382 Sutliff Rd,"Lisbon, IA 52253",(319) 455-4093,www.sutliffcider.com,41.884377,-91.386917
36 | Third Base Brewery,500 Blairs Ferry Road NE,"Cedar Rapids, IA 52402",(319) 378-9090,www.thirdbasebrewery.com,42.035095,-91.639674
37 | Toppling Goliath Brewing Company,310 College Drive,"Decorah, IA 52101",(563) 387-6700,www.tgbrews.com,43.308374,-91.797114
38 | Twisted Wine Brewery,3021 St Charles Road,"Saint Charles, IA 50240",NA,www.twistedvinebrewery.com,41.290292,-93.800555
39 | Van Houzen Brewing Company,6602 Ginger Avenue,"Newton, IAᅠ 50208",(319) 594-9684,NA,41.680283,-93.05762
40 | Worth Brewing Company,826 Central Ave,"Northwood, IA 50459",(641) 324-9899,www.worthbrewing.com,43.444065,-93.220261
--------------------------------------------------------------------------------
/01-base/json/ia-breweries.json:
--------------------------------------------------------------------------------
1 | [{"brewery":"515 Brewing Company","address":"7700 University Ave.","city":"Clive, IA 50325","phone":"(515) 661-4615","website":"www.515brewing.com","latitude":41.600002,"longitude":-93.722766},
2 | {"brewery":"Angry Cedar Brewing Company","address":"730 Technology Place\n","city":"Waverly, IA, 50677","phone":"NA","website":"www.angrycedar.com","latitude":42.726667,"longitude":-92.475278},
3 | {"brewery":"Appanoose Rapids Brewing Company","address":"332 East Main Street","city":"Ottumwa, IA, 52501","phone":"(641) 684-4008","website":"www.appanooserapidsbrewingcompany.com","latitude":41.015936,"longitude":-92.410008},
4 | {"brewery":"Backpocket Brewing Company","address":"903 Quarry Road","city":"Coralville, IA 52241","phone":"(319) 466-4444","website":"www.backpocketbrewing.com","latitude":41.681596,"longitude":-91.559932},
5 | {"brewery":"Beck’s Sports Brewery","address":"3295 University Ave","city":"Waterloo, IA 50701","phone":"(319) 234-4333","website":"www.barmuda.com/becks","latitude":42.500706,"longitude":-92.38998},
6 | {"brewery":"Boone Valley Brewing Company\n","address":"816 7th Street","city":"Boone, Iowa 50036","phone":"(515) 432-1232","website":"NA","latitude":42.062616,"longitude":-93.880685},
7 | {"brewery":"Briar Creek Brewery","address":"NA","city":"Janesville, IA 50647","phone":"NA","website":"www.briarcreekbrewery.com","latitude":42.627377,"longitude":-92.46536},
8 | {"brewery":"C.I.B. (Chefs in Black) Brewery","address":"39036 Aspen Road","city":"Macedonia, IA 51549","phone":"(515) 450-2981","website":"www.cibbrewery.com","latitude":41.175571,"longitude":-95.441562},
9 | {"brewery":"Confluence Brewing Company","address":"1235 Thomas Beck Rd., Suite A","city":"Des Moines, IA 50315","phone":"(515) 285-9005","website":"NA","latitude":41.568638,"longitude":-93.631768},
10 | {"brewery":"Court Avenue Brewing Company","address":"309 Court Ave","city":"Des Moines, IA 50309","phone":"(515) 282-2739","website":"www.courtavebrew.com","latitude":41.585502,"longitude":-93.620998},
11 | {"brewery":"Depot Deli Restaurant","address":"101 North Railroad Street","city":"Shenandoah, IA 51601","phone":"(712) 246-4444","website":"www.depotdeli.com","latitude":40.76499,"longitude":-95.376992},
12 | {"brewery":"Exile Brewing Company","address":"1514 Walnut Street","city":"Des Moines, IA 50309","phone":"(515) 883-2337","website":"NA","latitude":41.583013,"longitude":-93.637015},
13 | {"brewery":"Front Street Brewery","address":"208 E. River Rd.","city":"Davenport, IA 52801","phone":"(319) 322-1569","website":"www.frontstreetbrew.com","latitude":41.520357,"longitude":-90.572245},
14 | {"brewery":"Granite City Food & Brewery – Worthouse","address":"1722 Detroit Street","city":"Ellsworth, IA 50075","phone":"(515) 836-4060","website":"www.gcfb.net","latitude":42.3141,"longitude":-93.57481},
15 | {"brewery":"Granite City Food & Brewery – Cedar Rapids","address":"4755 First Avenue SE","city":"Cedar Rapids, IA 52403","phone":"(319) 395-7500","website":"www.gcfb.net/locations/loc_cedarrapids.cfm","latitude":42.025158,"longitude":-91.621528},
16 | {"brewery":"Granite City Food & Brewery – Clive","address":"12801 University Ave","city":"Clive, IA 50325","phone":"(515) 224-1300","website":"www.gcfb.net/locations/loc_clive.cfm","latitude":41.600851,"longitude":-93.79458},
17 | {"brewery":"Granite City Food & Brewery – Davenport","address":"5280 Utica Ridge Rd","city":"Davenport, IA 52807","phone":"(563) 344-9700","website":"www.gcfb.net/locations/loc_davenport.cfm","latitude":41.574625,"longitude":-90.513509},
18 | {"brewery":"Great River Brewery","address":"332 East 2nd Street","city":"Davenport, IA 52801","phone":"(319) 541-5160","website":"www.greatriverbrewery.com","latitude":41.521383,"longitude":-90.570087},
19 | {"brewery":"Keg Creek Brewing Company","address":"111 Sharp Street, PO Box 281","city":"Glenwood, IA 51534","phone":"(712) 520-9029","website":"www.kegcreekbrewing.com","latitude":41.047742,"longitude":-95.734534},
20 | {"brewery":"Lost Duck","address":"723 Avenue H","city":"Fort Madison, IA 52627","phone":"(319) 372-8255","website":"www.duckbrewing.com","latitude":40.630008,"longitude":-91.310758},
21 | {"brewery":"Madhouse Brewing Company\n","address":"403 W. 4th St. N.\n","city":"Newton, IA 50208","phone":"(641) 831-3392","website":"www.madhousebeer.com","latitude":41.702683,"longitude":-93.060109},
22 | {"brewery":"Millstream Brewing Company","address":"835 48th Ave","city":"Amana, IA 52203","phone":"(319) 622-3672","website":"www.millstreambrewing.com","latitude":41.797214,"longitude":-91.865153},
23 | {"brewery":"Number 7 Brewing","address":"302 SW Maple St.\n","city":"Ankeny, IA 50023","phone":"NA","website":"NA","latitude":41.729437,"longitude":-93.60883},
24 | {"brewery":"Old Man River Restaurant and Brewery","address":"123 A. St.","city":"McGregor, IA 52157","phone":"(563) 873-1999","website":"www.oldmanriverbrewery.com","latitude":43.024687,"longitude":-91.174673},
25 | {"brewery":"Olde Main Brewing Co.","address":"316 Main Street","city":"Ames, IA 50010","phone":"(515) 232-0553","website":"www.oldemainbrewing.com","latitude":42.024803,"longitude":-93.614693},
26 | {"brewery":"Peace Tree Brewing Company","address":"107 West Main Street","city":"Knoxville, Iowa 50138","phone":"(641) 842-2739","website":"www.peacetreebrewing.com","latitude":41.318956,"longitude":-93.09892},
27 | {"brewery":"Raccoon River Brewing Company","address":"200 Tenth Street","city":"Des Moines, IA 50309","phone":"(515) 362-5222","website":"www.raccoonbrew.com","latitude":41.584066,"longitude":-93.629609},
28 | {"brewery":"Rock Bottom Brewery","address":"4508 University Ave","city":"West Des Moines, IA 50266","phone":"(515) 267-8900","website":"www.rockbottom.com","latitude":41.600368,"longitude":-93.789561},
29 | {"brewery":"Sutliff Cider Company","address":"382 Sutliff Rd","city":"Lisbon, IA 52253","phone":"(319) 455-4093","website":"www.sutliffcider.com","latitude":41.884377,"longitude":-91.386917},
30 | {"brewery":"Third Base Brewery","address":"500 Blairs Ferry Road NE","city":"Cedar Rapids, IA 52402","phone":"(319) 378-9090","website":"www.thirdbasebrewery.com","latitude":42.035095,"longitude":-91.639674},
31 | {"brewery":"Toppling Goliath Brewing Company","address":"310 College Drive","city":"Decorah, IA 52101","phone":"(563) 387-6700","website":"www.tgbrews.com","latitude":43.308374,"longitude":-91.797114},
32 | {"brewery":"Twisted Wine Brewery","address":"3021 St Charles Road","city":"Saint Charles, IA 50240","phone":"NA","website":"www.twistedvinebrewery.com","latitude":41.290292,"longitude":-93.800555},
33 | {"brewery":"Van Houzen Brewing Company","address":"6602 Ginger Avenue","city":"Newton, IAï¾ 50208","phone":"(319) 594-9684","website":"NA","latitude":41.680283,"longitude":-93.05762},
34 | {"brewery":"Worth Brewing Company","address":"826 Central Ave","city":"Northwood, IA 50459","phone":"(641) 324-9899","website":"www.worthbrewing.com","latitude":43.444065,"longitude":-93.220261}]
--------------------------------------------------------------------------------
/02-final/json/ia-breweries.json:
--------------------------------------------------------------------------------
1 | var breweries = [{"brewery":"515 Brewing Company","address":"7700 University Ave.","city":"Clive, IA 50325","phone":"(515) 661-4615","website":"www.515brewing.com","latitude":41.600002,"longitude":-93.722766},
2 | {"brewery":"Angry Cedar Brewing Company","address":"730 Technology Place\n","city":"Waverly, IA, 50677","phone":"NA","website":"www.angrycedar.com","latitude":42.726667,"longitude":-92.475278},
3 | {"brewery":"Appanoose Rapids Brewing Company","address":"332 East Main Street","city":"Ottumwa, IA, 52501","phone":"(641) 684-4008","website":"www.appanooserapidsbrewingcompany.com","latitude":41.015936,"longitude":-92.410008},
4 | {"brewery":"Backpocket Brewing Company","address":"903 Quarry Road","city":"Coralville, IA 52241","phone":"(319) 466-4444","website":"www.backpocketbrewing.com","latitude":41.681596,"longitude":-91.559932},
5 | {"brewery":"Beck's Sports Brewery","address":"3295 University Ave","city":"Waterloo, IA 50701","phone":"(319) 234-4333","website":"www.barmuda.com/becks","latitude":42.500706,"longitude":-92.38998},
6 | {"brewery":"Boone Valley Brewing Company\n","address":"816 7th Street","city":"Boone, Iowa 50036","phone":"(515) 432-1232","website":"NA","latitude":42.062616,"longitude":-93.880685},
7 | {"brewery":"Briar Creek Brewery","address":"NA","city":"Janesville, IA 50647","phone":"NA","website":"www.briarcreekbrewery.com","latitude":42.627377,"longitude":-92.46536},
8 | {"brewery":"C.I.B. (Chefs in Black) Brewery","address":"39036 Aspen Road","city":"Macedonia, IA 51549","phone":"(515) 450-2981","website":"www.cibbrewery.com","latitude":41.175571,"longitude":-95.441562},
9 | {"brewery":"Confluence Brewing Company","address":"1235 Thomas Beck Rd., Suite A","city":"Des Moines, IA 50315","phone":"(515) 285-9005","website":"NA","latitude":41.568638,"longitude":-93.631768},
10 | {"brewery":"Court Avenue Brewing Company","address":"309 Court Ave","city":"Des Moines, IA 50309","phone":"(515) 282-2739","website":"www.courtavebrew.com","latitude":41.585502,"longitude":-93.620998},
11 | {"brewery":"Depot Deli Restaurant","address":"101 North Railroad Street","city":"Shenandoah, IA 51601","phone":"(712) 246-4444","website":"www.depotdeli.com","latitude":40.76499,"longitude":-95.376992},
12 | {"brewery":"Exile Brewing Company","address":"1514 Walnut Street","city":"Des Moines, IA 50309","phone":"(515) 883-2337","website":"NA","latitude":41.583013,"longitude":-93.637015},
13 | {"brewery":"Front Street Brewery","address":"208 E. River Rd.","city":"Davenport, IA 52801","phone":"(319) 322-1569","website":"www.frontstreetbrew.com","latitude":41.520357,"longitude":-90.572245},
14 | {"brewery":"Granite City Food & Brewery – Worthouse","address":"1722 Detroit Street","city":"Ellsworth, IA 50075","phone":"(515) 836-4060","website":"www.gcfb.net","latitude":42.3141,"longitude":-93.57481},
15 | {"brewery":"Granite City Food & Brewery – Cedar Rapids","address":"4755 First Avenue SE","city":"Cedar Rapids, IA 52403","phone":"(319) 395-7500","website":"www.gcfb.net/locations/loc_cedarrapids.cfm","latitude":42.025158,"longitude":-91.621528},
16 | {"brewery":"Granite City Food & Brewery – Clive","address":"12801 University Ave","city":"Clive, IA 50325","phone":"(515) 224-1300","website":"www.gcfb.net/locations/loc_clive.cfm","latitude":41.600851,"longitude":-93.79458},
17 | {"brewery":"Granite City Food & Brewery – Davenport","address":"5280 Utica Ridge Rd","city":"Davenport, IA 52807","phone":"(563) 344-9700","website":"www.gcfb.net/locations/loc_davenport.cfm","latitude":41.574625,"longitude":-90.513509},
18 | {"brewery":"Great River Brewery","address":"332 East 2nd Street","city":"Davenport, IA 52801","phone":"(319) 541-5160","website":"www.greatriverbrewery.com","latitude":41.521383,"longitude":-90.570087},
19 | {"brewery":"Keg Creek Brewing Company","address":"111 Sharp Street, PO Box 281","city":"Glenwood, IA 51534","phone":"(712) 520-9029","website":"www.kegcreekbrewing.com","latitude":41.047742,"longitude":-95.734534},
20 | {"brewery":"Lost Duck","address":"723 Avenue H","city":"Fort Madison, IA 52627","phone":"(319) 372-8255","website":"www.duckbrewing.com","latitude":40.630008,"longitude":-91.310758},
21 | {"brewery":"Madhouse Brewing Company\n","address":"403 W. 4th St. N.\n","city":"Newton, IA 50208","phone":"(641) 831-3392","website":"www.madhousebeer.com","latitude":41.702683,"longitude":-93.060109},
22 | {"brewery":"Millstream Brewing Company","address":"835 48th Ave","city":"Amana, IA 52203","phone":"(319) 622-3672","website":"www.millstreambrewing.com","latitude":41.797214,"longitude":-91.865153},
23 | {"brewery":"Number 7 Brewing","address":"302 SW Maple St.\n","city":"Ankeny, IA 50023","phone":"NA","website":"NA","latitude":41.729437,"longitude":-93.60883},
24 | {"brewery":"Old Man River Restaurant and Brewery","address":"123 A. St.","city":"McGregor, IA 52157","phone":"(563) 873-1999","website":"www.oldmanriverbrewery.com","latitude":43.024687,"longitude":-91.174673},
25 | {"brewery":"Olde Main Brewing Co.","address":"316 Main Street","city":"Ames, IA 50010","phone":"(515) 232-0553","website":"www.oldemainbrewing.com","latitude":42.024803,"longitude":-93.614693},
26 | {"brewery":"Peace Tree Brewing Company","address":"107 West Main Street","city":"Knoxville, Iowa 50138","phone":"(641) 842-2739","website":"www.peacetreebrewing.com","latitude":41.318956,"longitude":-93.09892},
27 | {"brewery":"Raccoon River Brewing Company","address":"200 Tenth Street","city":"Des Moines, IA 50309","phone":"(515) 362-5222","website":"www.raccoonbrew.com","latitude":41.584066,"longitude":-93.629609},
28 | {"brewery":"Rock Bottom Brewery","address":"4508 University Ave","city":"West Des Moines, IA 50266","phone":"(515) 267-8900","website":"www.rockbottom.com","latitude":41.600368,"longitude":-93.789561},
29 | {"brewery":"Sutliff Cider Company","address":"382 Sutliff Rd","city":"Lisbon, IA 52253","phone":"(319) 455-4093","website":"www.sutliffcider.com","latitude":41.884377,"longitude":-91.386917},
30 | {"brewery":"Third Base Brewery","address":"500 Blairs Ferry Road NE","city":"Cedar Rapids, IA 52402","phone":"(319) 378-9090","website":"www.thirdbasebrewery.com","latitude":42.035095,"longitude":-91.639674},
31 | {"brewery":"Toppling Goliath Brewing Company","address":"310 College Drive","city":"Decorah, IA 52101","phone":"(563) 387-6700","website":"www.tgbrews.com","latitude":43.308374,"longitude":-91.797114},
32 | {"brewery":"Twisted Wine Brewery","address":"3021 St Charles Road","city":"Saint Charles, IA 50240","phone":"NA","website":"www.twistedvinebrewery.com","latitude":41.290292,"longitude":-93.800555},
33 | {"brewery":"Van Houzen Brewing Company","address":"6602 Ginger Avenue","city":"Newton, IAï¾ 50208","phone":"(319) 594-9684","website":"NA","latitude":41.680283,"longitude":-93.05762},
34 | {"brewery":"Worth Brewing Company","address":"826 Central Ave","city":"Northwood, IA 50459","phone":"(641) 324-9899","website":"www.worthbrewing.com","latitude":43.444065,"longitude":-93.220261}]
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | #Building your first Leaflet.js map
2 | This is the code behind my NICAR 2017 session on making maps with [Leaflet.js](https://github.com/Leaflet/Leaflet).
3 |
4 | This is [map we will be building](http://csessig86.github.io/leaflet-maps-intro/).
5 |
6 | ####Pre: Why Leaflet.js?
7 | * Free, open source and actively maintained
8 | * Well documented with great examples
9 | * Has a huge community behind it
10 | * Used by a lot of people
11 | * Minimal amount of code
12 | * Mobile friendly
13 | * Can handle thousands of data points without loading too slowly
14 | * [Plugins](http://leafletjs.com/plugins.html)! Example of the [markercluster plugin](http://csessig86.github.io/tabletop_to_leaflet/#cluster)
15 |
16 | ####Pre: The set up
17 | * This repo has two directories:
18 | * 01-base contains the base files you will need to get started. All the files you need have been created here, but none of the mapping code has been written yet.
19 | * 02-final is the final project we are going to build.
20 |
21 | ####1. Getting started
22 | * Download this repo onto your computer. Then open up the 01-base directory you created in a text editor. We'll be adding our mapping code to the files in this directory.
23 |
24 | * You'll notice at the bottom of the index.html file these lines:
25 | ```html
26 |
27 |
28 |
29 | ```
30 |
31 | * These link to the data sources we're going to be using: [JSON data](http://www.copterlabs.com/json-what-it-is-how-it-works-how-to-use-it/) of breweries in Iowa and [GeoJSON data](http://geojson.org/) of the counties in Iowa.
32 |
33 | ####2. Base map
34 | * Add this to js/script.js:
35 | ```javascript
36 | var layer = new L.StamenTileLayer('toner-background');
37 |
38 | var map = new L.Map('map').setView([42,-93],7);
39 | map.addLayer(layer);
40 | ```
41 |
42 | ####3. CSS
43 | * Add this to css/style.css:
44 | ```css
45 | #map {
46 | width: 100%;
47 | height: 500px;
48 | }
49 |
50 | ```
51 | * This gets us a map without any data points that looks like:
52 | 
53 |
54 | ####5. Add data to map
55 | * Our sample dataset is [a list of breweries in Iowa](https://docs.google.com/spreadsheets/d/1M6mREJiDMQ1NTbdbOXiw0sWN_6DE7E33JJY503GS7tc/pub?output=html). I've already included lat, long information for each brewery and converted the CSV into a JSON file. You must have lat, long information for each location for Leaflet to put them on the map.
56 |
57 | * Pro-tip: If you need a site to convert CSVs into JSON files, check out [Mr. Data Converter](http://shancarter.github.io/mr-data-converter/). And if you're looking for a site that can geocode addresses in a Google spreadsheet, check out [this site](http://gmaps-samples.googlecode.com/svn/trunk/spreadsheetsgeocoder/geocodespreadsheet.htm).
58 |
59 | * The breweries JSON data is one array. Each brewery is an object within that array. Objects have keys and values and each represent a data point. For instance, in the breweries data, one of the keys is address. The value is address for the specific brewery.
60 |
61 | * You need to make sure the array is a variable, so go into the file and add this before it:
62 | ```javascript
63 | var breweries =
64 | ```
65 |
66 | * This makes it easy for us to loop through that variable of our JSON array:
67 | ```javascript
68 | for (var num = 0; num < breweries.length; num++) {
69 | var brewery = breweries[num];
70 | var brewery_lat = brewery["latitude"];
71 | var brewery_long = brewery["longitude"];
72 |
73 | L.marker([brewery_lat, brewery_long]).addTo(map);
74 | }
75 | ```
76 | * This loops through each brewery, grabs the brewery's latitude and longitude information and puts it on the map. The [L.marker function](http://leafletjs.com/reference.html#marker) is a Leaflet function that is used to create a new marker for each brewery we are looping through. It's placed on the map based on the brewery's latitude and longitude information.
77 |
78 | * Your map should now look like:
79 | 
80 |
81 | ####4. Add GeoJSON data
82 | * The second dataset we will be working is a list of counties in Iowa, which is available in GeoJSON format [here](http://catalog.opendata.city/dataset/iowa-counties-polygon/resource/52b6d8b4-b203-4ab3-94db-e5e93c335a14). I've downloaded this already and included it within the data directory.
83 |
84 | * NOTE: The counties also have population data in them, which we use later.
85 |
86 | * Like with our breweries, we need to make the GeoJSON object a variable so it can be easiliy called within script.js:
87 | ```javascript
88 | var iowa_counties =
89 | ```
90 |
91 | * Adding our counties to the map only takes one line of code:
92 | ```javascript
93 | L.geoJson(iowa_counties).addTo(map);
94 | ```
95 |
96 | * You'll what to place this ABOVE the for loop that places the marker on the map. The makes sure the counties appear under the markers.
97 |
98 | * Refresh your map and you'll see the counties now on the map:
99 | 
100 |
101 | ####5. Styling the counties
102 | * The counties kind of look ugly right now. We can fix that by extending the geojson object we added:
103 |
104 | ```javascript
105 | function setStyle(feature) {
106 | return {
107 | opacity: 1,
108 | weight: 2,
109 | color: "#FFF",
110 | fillColor: "#005824",
111 | fillOpacity: 0.8
112 | }
113 | }
114 |
115 | L.geoJson(iowa_counties, {
116 | style: setStyle
117 | }).addTo(map);
118 | ```
119 |
120 | * Every time a county is looped through, the [Leaflet GeJSON function](http://leafletjs.com/reference.html#geojson) calls the [style method](http://leafletjs.com/reference.html#geojson-style), which, in turn, calls the setSyle function. The function then returns styles for the particular county. Right now, we are returning the same fillColor for each county, so all the counties will be colored the same.
121 |
122 | * For more information on the different styling options available for GeoJSON layers, visit [this page](http://mourner.github.io/Leaflet/reference.html#path-options).
123 |
124 | * Your map should now look like:
125 | 
126 |
127 | ####6. Color counties based on population data
128 | * Our map is cool and all but the counties don't tell us much. Wouldn't it be neat if we could shade the counties based on how many people lived within them? Fortunately we can do that relatively easily in Leaflet.
129 |
130 | * The final piece of data we will be working with is population data from the [U.S. Census](http://www.census.gov/). We will create a basic [choropleth map](http://leafletjs.com/examples/choropleth.html) where the counties will be shaded based on their population. The more people, the darker the county.
131 |
132 | * I've already downloaded the data from the [Census Reporter site](http://censusreporter.org/data/table/?table=B01003&geo_ids=04000US19,050|04000US19,050|04000US19&primary_geo_id=04000US19) and merged it into the county GeoJSON file that's on the map. I used [QGIS](http://www.qgis.org/en/site/) to do this. If you're not familiar with QGIS, I recommend checking it out. It's a like watered-down version of [ArcGIS](https://www.arcgis.com/features/). But unlike ArcGIS, it's free.
133 |
134 | * Instead setting the same color for each county, we're going to grab the population for each county we're looping through and set the color based on its value:
135 | ```javascript
136 | function setColor(population) {
137 | var population_num = parseInt(population)
138 |
139 | if (population_num > 150000) {
140 | return '#005824';
141 | } else if (population_num > 125000) {
142 | return '#238b45';
143 | } else if (population_num > 100000) {
144 | return '#41ae76';
145 | } else if (population_num > 75000) {
146 | return '#66c2a4';
147 | } else if (population_num > 50000) {
148 | return '#99d8c9';
149 | } else if (population_num > 25000) {
150 | return '#ccece6';
151 | } else {
152 | return '#edf8fb';
153 | }
154 | }
155 |
156 | function setStyle(feature) {
157 | return {
158 | opacity: 1,
159 | weight: 2,
160 | color: "#FFF",
161 | fillColor: setColor(feature.properties.population),
162 | fillOpacity: 0.8
163 | }
164 | }
165 |
166 | L.geoJson(iowa_counties, {
167 | style: setStyle
168 | }).addTo(map);
169 | ```
170 |
171 | * Each county setStyle loops through is an object, with a couple of data points, including the shape of the county and the population (which I added with QGIS). We're after the county's population, and we can grab it by calling feature.properties.population.
172 |
173 | * This value is sent to the setColor function, which sets the color of the county based on its value. The population is stored as a string in the object, so we need to convert it to an integer using the handy [parseInt function](http://www.w3schools.com/jsref/jsref_parseint.asp).
174 |
175 | * The setColor function looks at the population and it assigns it a color. The higher the population, the darker the green. The colors were grabbed from [ColorBrewer](http://colorbrewer2.org/).
176 |
177 | * Now refresh the map one more time. You have created a beautiful choropleth map with markers on top of it. Congrats!
178 | 
179 |
180 | ####Bonus: Adding popups to the markers
181 |
182 | * If we want to add popups to the markers on the map, we need to change our for loop to look like:
183 | ```javascript
184 | for (var num = 0; num < breweries.length; num++) {
185 | var brewery = breweries[num];
186 | var brewery_lat = brewery["latitude"];
187 | var brewery_long = brewery["longitude"];
188 | var brewery_name = brewery["brewery"];
189 | var brewery_address = brewery["address"];
190 | var brewery_city = brewery["city"];
191 |
192 | var marker = L.marker([brewery_lat, brewery_long]).addTo(map);
193 |
194 | var popup_html = '