azavea / pfb-network-connectivity

PFB Bicycle Network Connectivity
Other
40 stars 10 forks source link

Make proof-of-concept React Leaflet map showing BNA census blocks overlay #861

Closed KlaasH closed 2 years ago

KlaasH commented 2 years ago

The PeopleForBikes City Ratings site uses the output of the BNA analysis for a map, but currently it's just a screen-shot of a handmade map. We want it to draw directly from the map data produced by the BNA. The simplest way to do that seems likely to be with a simple Leaflet map (with a base map, zoom controls, and a legend, but no layer control) that pulls the tiles from the BNA's tile endpoint.

To help facilitate that, we said we'd make a simple proof-of-concept Leaflet map, in React, since that's what the City Ratings project is written in.

The pages on City Ratings already have the job UUIDs from the BNA, which I believe is all you need to access the tile endpoints.

aaronxsu commented 2 years ago

Overview

The changes included in the following zipped file are:

pfb-city-ratings-main-leaflet-map-v20220203.zip

Demo

Screen Shot 2022-02-03 at 5 25 01 PM

Notes

Testing Instructions

Checklist

Resolves (this issue itself)

KlaasH commented 2 years ago

This worked great! I put the modified files into a checkout of the repo and fired it up and the map showed up looking good.

There were some formatting changes--I think your editor must have run Prettier or something similar--so I ended up reverting the existing files and pulling only the substantive changes out of them, to avoid muddying the waters in the diff. In doing that, I noticed that adjusting the z-index on only the navbar seemed to work to also prevent the map from showing up above the search overlay. I assume that's because in the DOM, the search stuff is defined inside the navbar. So I didn't include the z-index changes to search.js in the version I sent.

It turned out that my access to the repo is read-only, so pushing a branch wasn't an option. So instead I wrote things up in an email and attached a diff and the modified files. I'll reproduce that below.

I'm not sure what the next steps will be--i.e. whether John will just run with what we sent or if there will be more follow-up--but we've certainly accomplished the task of making a proof-of-concept map, so I'm going to close this issue.

Here are the writeup and attachments from my email, sent today (2/10/22):


This email is going to look a lot like a draft PR, since that's how I was thinking of it until I realized my repo access is read-only. But I've attached the output of git diff and a zip file containing only the new and modified files. Unzipping it on top of a checkout of the repo (and running yarn install) should give you a working version of the modified app.

What the modifications do is replace the static images in the "Network analysis" section that were exported from BNA data with a proof-of-concept Leaflet map that directly pulls the census blocks tiles from the BNA tile endpoint. The map also reproduces the legend from the BNA map, and offers a zoom control, but leaves off the other controls (like the layer picker). Some notes:

bna-map-demo.diff.txt bna-map-demo.zip