GreenInfo-Network / nyc-crash-mapper-chart-view

Chart view for NYC Crash Mapper that allows for viewing Trends, Comparing, and Ranking of various NYC geographies
http://vis.crashmapper.org
MIT License
2 stars 1 forks source link

Enable link back to Map from Chart view #48

Closed danrademacher closed 6 years ago

danrademacher commented 6 years ago

Known need we hadn't logged: Enable link back to Map view.

First task: Decide which params to carry over.

Sample Chart UI params:

cfat=false
cinj=true
geo=city_council
mfat=false
minj=true
p1end=2017-11
p1start=2016-11
p2end=2016-11
p2start=2015-11
pfat=false
pinj=true
primary=3
reference=citywide
secondary=5
view=trend

Map UI Params for a similar search:

cfat=false
cinj=true
endDate=2017-11
geo=City%20Council%20District
identifier=3
lat=40.746639222374434
lng=-73.9857530593872
lngLats=%255B%255D
mfat=false
minj=true
noInjFat=false
pfat=false
pinj=true
startDate=2016-11
zoom=14

Matching the two:

CHART MAP
cfat cfat
cinj cinj
p1end endDate
geo geo
primary identifier
  lat
  lng
  lngLats
mfat mfat
minj minj
  noInjFat
pfat pfat
pinj pinj
p1start startDate
  zoom
p2end  
p2start  
reference  
secondary  
view  
danrademacher commented 6 years ago

Looks like values in geo are different between the two, however. In chart, we have geo=city_council but in map City%20Council%20District.

Need to normalize map values to match chart? Or just do a crosswalk?

clhenrick commented 6 years ago

It would probably make sense to normalize them. I'll have to take a look at how the map handles parsing the query params.

clhenrick commented 6 years ago

@danrademacher the problem I'm running into with this is that the chart view app has no way of knowing what the map zoom and center should be. So while the other query params may be sent, the map will load without being zoomed and centered on the desired area.

Here's an example stateful URL that would be used from the chart view to point to the map view so you can see what I mean: http://crashmapper.org/#/?cfat=false&cinj=true&endDate=2017-11&geo=city_council&identifier=27&mfat=false&minj=true&pfat=false&pinj=true&startDate=2016-11

clhenrick commented 6 years ago

Oh but I haven't yet pushed the updates to the Map view that would make that work so nevermind.

clhenrick commented 6 years ago

Noting that a possible solution could be for the map view to request the polygon that matches "geo" and "identifier", then use the polygon to set the map zoom and center, but that would be another feature to build out in the map.

clhenrick commented 6 years ago

Suppose another alternative is to store the map zoom and center in the chart view app when a user comes from the map view app. That way if someone wasn't changing their geography type or identifier they could go back and forth between the two. This isn't an ideal solution though as it assumes that someone isn't changing the geo type or identifier.

danrademacher commented 6 years ago

I wondered about that, forgot to note possible simpler solution: Just default map zoom to whole region, but keep geom selected. Like this: http://crashmapper.org/#/?cfat=false&cinj=false&endDate=2017-11&geo=City%20Council%20District&identifier=3&lat=40.70484714530104&lng=-73.89678955078125&lngLats=%255B%255D&mfat=false&minj=false&noInjFat=false&pfat=false&pinj=false&startDate=2017-11&zoom=11

Maybe not ideal, but would allow just a single "baked" or static set of center and zoom coords coming from Chart to Map

clhenrick commented 6 years ago

Hmmm, I suppose that could work as a temporary solution.

clhenrick commented 6 years ago

Implemented: https://greeninfo-network.github.io/nyc-crash-mapper-chart-view/index.html?cfat=false&cinj=true&geo=neighborhood&mfat=false&minj=true&p1end=2017-11&p1start=2016-11&p2end=2016-11&p2start=2015-11&pfat=false&pinj=true&primary=East%20Flatbush&reference=citywide&secondary=Bedford-Stuyvesant&view=trend

clhenrick commented 6 years ago

Reopening per https://github.com/clhenrick/nyc-crash-mapper/issues/62#issuecomment-343271862