sfbrigade/sf-crime-data

Add Campus Safety Category to Open with Geojson.io Call

Opened this issue · 2 comments

Expected behavior

All table columns plus location (lat/long) will be sent to Geojson.

Actual behavior

The following columns are passed to Geojson:
address category date descript incidntnum location pddistrict resolution time

Steps to reproduce

Run a search that returns results.
Click on the blue button to "Open with Geojson.io".
http://geojson.io site opens with passed JSON displayed on the right side of the screen.

Steps to fix

Add Campus Safety Category to the JSON data passed to Geojson.io

Assigning to myself - rethinking the requirement behind this button.

The stumbling block here is that Campus Safety Category is a category we calculate on our app via _csCategoryCheck.

This makes things a little harder, considering the request we're sending to geojson.io basically says "Hey GeoJson.io, can you do a request to SFGov with these params?" via a data:text/x-url link.

What we would need to do instead is to take our data set, which has the Campus Safety Category calculated on it, and send that data to GeoJson.io directly.

Looks like this can be done with a data=data:application/json, and some usage of encodeURIComponent(JSON.stringify(our_great_data))

Looks like however, the buttons generation method refreshDownloadButtonUrls is called before the data is loaded, so some refactoring will need to happen to ensure the data is loaded before the buttons are populated.