Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f7e8af2
Update README.md
JackDougherty Jan 28, 2019
5e3ca41
Change awesome-markers to svg to allow hex and material icons
ilyankou May 23, 2019
c636b93
Fix Nominatim geocoder
ilyankou Feb 24, 2020
1edb0ee
Update README.md
ilyankou May 13, 2020
2f61419
Update README.md
ilyankou May 13, 2020
a8ded6a
Create FUNDING.yml
ilyankou Jun 2, 2020
c34d820
Fetch data using API v4 not tabletop
ilyankou Aug 1, 2020
ffc3fa8
Create blank.txt
JackDougherty Aug 7, 2020
0063247
Add files via upload
JackDougherty Aug 7, 2020
8b14bf7
Delete blank.txt
JackDougherty Aug 7, 2020
3c1dfdd
Read Options.csv from root; make sure group label icons appear in legend
ilyankou Sep 1, 2020
49dca5a
Replace .get(0) with .first() to account for no polygons no polylines
ilyankou Sep 2, 2020
1b623c6
Delete empty comment from html
ilyankou Sep 10, 2020
ffa534b
Add favicon
ilyankou Sep 11, 2020
0bfec18
Adjust favicon slightly
ilyankou Sep 11, 2020
4973618
updated CDNs and README to prep for next version
JackDougherty Sep 27, 2020
2ed750a
Update README.md
JackDougherty Sep 27, 2020
b66a387
Fix CSV loading
ilyankou Sep 28, 2020
3f19c97
Fix Polygons.csv path typo
ilyankou Sep 28, 2020
f997988
Move markers to media/ and rename geometry folder
ilyankou Sep 28, 2020
66323be
Remove csv-/ folder
ilyankou Sep 28, 2020
ca318c1
add csv folder for testing
JackDougherty Sep 28, 2020
75d6772
removed csv folder
JackDougherty Sep 28, 2020
8d0b1d7
Update README.md
JackDougherty Sep 28, 2020
4632904
Update README.md
JackDougherty Sep 28, 2020
421763a
Update README.md
JackDougherty Sep 28, 2020
8719b0f
Add GA
ilyankou Sep 29, 2020
865ee46
Update README.md
JackDougherty Sep 29, 2020
55d023f
Update README.md
JackDougherty Oct 3, 2020
49461f7
Create upload-data-here.md
JackDougherty Oct 23, 2020
8e10169
updating demo
JackDougherty Jan 4, 2021
de976ef
Revert "updating demo"
JackDougherty Jan 4, 2021
861d8c2
Disable map tap to fix bugs in Safari
ilyankou Jan 5, 2021
394c9ac
Fix font awesome markers
ilyankou Jan 5, 2021
a1e309b
updated demo
JackDougherty Jan 5, 2021
e0c0b4e
Update preview.jpg
JackDougherty Jan 5, 2021
45be9a3
Fix point legend icon color bug
ilyankou Jan 11, 2021
bf5e117
updated media
JackDougherty Feb 26, 2021
5207744
Add support for basemap api keys
ilyankou Aug 19, 2023
52b80ba
update leaflet and leaflet-providers in index
JackDougherty Sep 12, 2023
82189df
Fix duplicating icon in legend; Safari zoomed display
ilyankou Mar 2, 2024
a8aa235
Merge pull request #132 from Picturedigits/main
JackDougherty Mar 2, 2024
6b0c786
Preserve polyline order in legend
ilyankou Mar 14, 2024
4b6cb0c
Merge pull request #133 from Picturedigits/main
JackDougherty Mar 15, 2024
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
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [handsondataviz]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
google-doc-url.js
.DS_Store
83 changes: 62 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,76 @@
# Leaflet Maps with Google Sheets
Customize Leaflet maps with a linked Google Sheets template and GeoJSON data on GitHub
Customize Leaflet maps with a linked Google Sheets template or CSV files and GeoJSON data on GitHub

![Preview](preview.jpg)

## Live links (replace with your own)
- Leaflet Map https://jackdougherty.github.io/leaflet-maps-with-google-sheets/index.html
- Leaflet Map https://handsondataviz.github.io/leaflet-maps-with-google-sheets/
- Google Sheets template https://docs.google.com/spreadsheets/d/1ZxvU8eGyuN9M8GxTU9acKVJv70iC3px_m3EVFsOHN9g/edit#gid=0

## Create your own
- See video with step-by-step tutorial in *Data Visualization for All* http://www.datavizforall.org/leaflet/with-google-sheets/
See step-by-step tutorial in *Hands-On Data Visualization* https://handsondataviz.org/leaflet-maps-with-google-sheets.html

#### Geocode your address data with Google Sheets add-on
To geocode (find latitude and longitude coordinates), we recommend installing the free [Geocoding by SmartMonkey add-on for Google Sheets](https://gsuite.google.com/marketplace/app/geocoding_by_smartmonkey/1033231575312). Insert your addresses in place of the samples in the Geocoding Details tab, then use Add-Ons > Geocoding > Geocode Details menu. Learn more in *Hands-On Data Visualization* https://handsondataviz.org/geocode.html

![Geocoding](geocode.png)

#### To finalize your map, you need to either:
- Download each Google Sheets tab as a CSV file and upload into a `csv` subfolder in your GitHub repo
- OR
- Get your own Google Sheets API Key to insert into `google-doc-url.js`

See Steps G or H in the tutorial https://handsondataviz.org/leaflet-maps-with-google-sheets.html

## Update your code for any pre-October 2020 maps before January 2021
If you used our code to create a map prior to October 2020, you will need to update your version before January 26, 2021 for it to continue to work. Google announced that it will [migrate from Google Sheets API v3 to v4 in Jan 2021](https://developers.google.com/sheets/api/v3), and we updated our code to v1.2 on September 29th to address Google's changes.

Four options to update your code:

Option A: Use your existing code and pull your data from CSV files rather than a linked Google Sheet. This avoids the need for a Google Sheets API key, but does not take advantage of our other code updates.

1. Go to your linked Google Sheet, and for each tab, *File > Download* in CSV format, and rename them this way: Options.csv, Points.csv, etc.
2. Log into the web interface of your GitHub map repo.
3. Create a new subfolder named `csv` in your GitHub repo, by selecting *Add file > Create a file* and typing in `csv/`. The forward slash indicates it is a folder, not a file.
4. In your GitHub repo, upload each CSV file you created into this new `csv` subfolder.
5. In your Github repo, open the `google-doc-url.js` file, scroll to the bottom of the page, and delete it.
Now the code automatically searches for data in your CSV folder, rather than your Google Sheet. If desired, you can continue to use the Google Sheet to edit your map content and upload those changes to the CSV folder each time, or edit the CSV files directly.

OR

Option B: If you understand (or are willing to learn about) [GitHub Desktop](https://handsondataviz.org/github-desktop-atom.html), use it to move copies of the newer code (index.html, scripts folder, style.css, etc.) into your repo via your local computer. In the `google-doc-url.js` file, copy and paste the Google Sheets API key that appears in the lower half of our code, but keep your own Google Sheets ID that appears in the upper-half of your code.

OR

Option C: If you originally "forked" a copy of our code, create a GitHub "pull request" to update your repo with our code revisions, including the Google Sheets API key. We recommend this option only if you understand (or are willing to learn about) GitHub pull requests, and can deal with resolving conflicts between your code and our updated code.
Warning: Since this operation might overwrite some of your code, go to *Code > Download ZIP* to make a backup to your local computer.
1. Log into the web interface of your GitHub storymap repository.
2. Click *Pull requests* and click the green button for a *New pull request*.
3. On the *Comparing Changes* page, use the menus to pull code *into* your repo *from* the original repo, named HandsOnDataViz/leaflet-maps-with-google-sheets. GitHub may warn that you cannot automatically merge the files, but proceed anyways.
4. You may need to click the *Resolve conflicts* button on the next screen, which means you need to sort out which portions of your code to keep and which portions of our code to accept. Generally speaking, you should accept our updates for index.html, style.css, and most scripts.js, while keeping your own content for README.md, media, and geojson folder content. In the google-doc-url.js file, you should keep your own Google Sheet ID, but temporarily add our Google Sheets API key until you create your own. In GitHub, you can resolve code conflicts by deleting/keeping lines in specific files.

OR

Option D: Start over with a brand-new repo, and migrate your existing map content. Make a copy of our newer code by clicking the green 'Use template' button. Migrate any media folder or geodata folder content from your old repo to your new repo, by downloading to your local computer and uploading to GitHub. Reconnect your Google Sheet ID to the `google-doc-url.js` file in your new repo.

## Credits (and licenses)
Developed by [Ilya Ilyankou](https://github.com/ilyankou) and [Jack Dougherty](https://github.com/jackdougherty) with support from Trinity College CT, using a [Google Sheets](https://www.google.com/sheets/about/) template, with these open-source components:
- Inspired by: Code for Atlanta mapsfor.us (2016) https://github.com/codeforatlanta/mapsforus (BSD-3-Clause)
- Leaflet v1.0.3 https://leafletjs.com (BSD-2-Clause)
- jQuery v3.2.0 https://code.jquery.com (MIT)
- leaflet-providers (v1.1.15, manually updated for Carto https) https://github.com/leaflet-extras/leaflet-providers (BSD-2-Clause)
- leaflet-locatecontrol (v0.60.0) https://github.com/domoritz/leaflet-locatecontrol (MIT)
- Leaflet.markercluster (v1.0.4) https://github.com/Leaflet/Leaflet.markercluster (MIT)
- Leaflet.MarkerCluster.LayerSupport (v.1.0.3) https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport (MIT)
Developed by [Ilya Ilyankou](https://github.com/ilyankou) and [Jack Dougherty](https://github.com/jackdougherty) with support from Trinity College CT. Inspired by Code for Atlanta mapsfor.us (2016) https://github.com/codeforatlanta/mapsforus (BSD-3-Clause)

We use [Google Sheets API version 4](https://developers.google.com/sheets/api), with these open-source components:

- Leaflet v1.7.1 https://leafletjs.com (BSD-2-Clause)
- jQuery v3.5.1 https://code.jquery.com (MIT)
- PapaParse v5.3.0 to parse CSV with JavaScript (MIT)
- Font Awesome (v4.7) https://cdn.fontawesome.com (MIT, SIL OFL 1.1)
- Leaflet.awesome-markers (v2.0.4) https://github.com/sigma-geosistemas/Leaflet.awesome-markers (MIT)
- leaflet-providers (v1.10.2) https://github.com/leaflet-extras/leaflet-providers (BSD-2-Clause)
- Leaflet.awesome-markers (v2.0.4), manually updated to svg to allow hex and material icons https://github.com/sigma-geosistemas/Leaflet.awesome-markers (MIT)
- Leaflet.markercluster (v1.4.1) https://github.com/Leaflet/Leaflet.markercluster (MIT)
- Leaflet.MarkerCluster.LayerSupport (v.2.0.1) https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport (MIT)
- Leaflet Control Geocoder v1.13.0 https://github.com/perliedman/leaflet-control-geocoder (BSD 2-Clause)
- leaflet-locatecontrol (v0.72.0) https://github.com/domoritz/leaflet-locatecontrol (MIT)
- jQuery-CSV (v1.0.11) https://github.com/evanplaice/jquery-csv (MIT)
- DataTables (v1.10.22) by SpryMedia Ltd. https://datatables.net (MIT)
- Material icons https://material.io/resources/icons/ (Apache)
- Single Element CSS Spinner (31 May 2016) https://github.com/lukehaas/css-loaders (MIT)
- Tabletop.js gives spreadsheets legs, by returning Google Sheets data in JSON format (v1.5.1) https://github.com/jsoma/tabletop (MIT)
- Google Colour Palette Generator (2015) https://github.com/google/palette.js (MIT)
- Google Sheets Geocoder (v1.0) by Ilya Ilyankou and Jack Dougherty https://github.com/jackdougherty/google-sheets-geocoder (no license)
- polylabel (Dec. 2016 customized) https://github.com/mapbox/polylabel to optimally place text labels in a polygon (ISC), with TinyQueue (v1.1.0) (https://github.com/mourner/tinyqueue), polylabel's dependency (ISC)
- jQuery-CSV (v0.71) https://github.com/evanplaice/jquery-csv (MIT)
- DataTables (v1.10.13) by SpryMedia Ltd. https://datatables.net (MIT)
- [Leaflet Control Geocoder](https://github.com/perliedman/leaflet-control-geocoder) by @perliedman (BSD 2-Clause)

## Please submit any pull requests to our DEV repo
- Leaflet Map FOR DEVELOPMENT https://jackdougherty.github.io/leaflet-maps-with-google-sheets-dev/index.html
- Google Sheet FOR DEVELOPMENT https://docs.google.com/spreadsheets/d/1_xjrH3gSImzRKqIkhRAqpAAMjH387yaBWfGbidkKtqM/
1 change: 1 addition & 0 deletions csv/upload-data-here.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Option: upload your Google Sheets data in separate CSV files here, as described in https://handsondataviz.org/leaflet-maps-with-google-sheets/
Binary file added favicon.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 geocode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading