From 78d9ef568f3e3c547542302758ecc98feb8d5e9f Mon Sep 17 00:00:00 2001 From: Alexandra Ulsh Date: Sun, 22 Dec 2019 13:07:20 +0100 Subject: [PATCH 1/5] Updates URL in Jump script to Uber endpoint --- scripts/jump.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jump.js b/scripts/jump.js index 928cab8..7718d8a 100644 --- a/scripts/jump.js +++ b/scripts/jump.js @@ -2,7 +2,7 @@ const request = require('request'); const turf = require('@turf/turf'); const dcNeighborhoodData = 'https://opendata.arcgis.com/datasets/f6c703ebe2534fc3800609a07bad8f5b_17.geojson'; -const jumpData = 'https://dc.jumpmobility.com/opendata/free_bike_status.json'; +const jumpData = 'https://gbfs.uber.com/v1/dcb/free_bike_status.json'; function jumpArray(){ let bikeArray = []; From 2061f3d8cfe667cd88d2bc7676555aa2b68afd37 Mon Sep 17 00:00:00 2001 From: Alexandra Ulsh Date: Sun, 22 Dec 2019 13:42:45 +0100 Subject: [PATCH 2/5] Removes Jump from client-side maps.js due to CORS error --- map.js | 87 ++++------------------------------------------------------ 1 file changed, 5 insertions(+), 82 deletions(-) diff --git a/map.js b/map.js index 20a1220..0f2d80a 100644 --- a/map.js +++ b/map.js @@ -42,36 +42,7 @@ function cabiData() { }); } -function jumpData(){ - let bikeArray = []; - - return new Promise((resolve) => { - let request = new XMLHttpRequest(); - request.open('GET', 'https://dc.jumpmobility.com/opendata/free_bike_status.json'); - request.responseType = 'json'; - request.send(); - request.onload = () => { - const bikes = request.response.data.bikes; - bikes.forEach(bike => { - let lonLat = []; - lonLat.push(bike.lon); - lonLat.push(bike.lat); - bikeArray.push(lonLat); - }); - resolve(bikeArray); - }; - }); -} - -function isNumber(number) { - if (typeof number !== 'number') { - return false; - } else { - return true; - } -} - -function loadDcNeighborhoods(bikeshareData, jumpData) { +function loadDcNeighborhoods(bikeshareData) { let request = new XMLHttpRequest(); request.open('GET', 'https://opendata.arcgis.com/datasets/f6c703ebe2534fc3800609a07bad8f5b_17.geojson'); @@ -80,12 +51,10 @@ function loadDcNeighborhoods(bikeshareData, jumpData) { request.onload = () => { const cabiStations = new FeatureCollection(bikeshareData); const neighborhoods = request.response.features; - const jumpBikes = turf.points(jumpData); neighborhoods.forEach(neighborhood => { const polygon = turf.polygon(neighborhood.geometry.coordinates); const cabiWithin = turf.pointsWithinPolygon(cabiStations, polygon); - const jumpWithin = turf.pointsWithinPolygon(jumpBikes, polygon); let totalBikes = 0; cabiWithin.features.forEach(station =>{ @@ -93,7 +62,6 @@ function loadDcNeighborhoods(bikeshareData, jumpData) { }); neighborhood.properties.cabiBikes = totalBikes; - neighborhood.properties.jumpBikes = jumpWithin.features.length; map.addLayer({ id: `cabibikes-${neighborhood.properties.OBJECTID}`, @@ -125,36 +93,6 @@ function loadDcNeighborhoods(bikeshareData, jumpData) { } }); - map.addLayer({ - id: `jumpbikes-${neighborhood.properties.OBJECTID}`, - type: 'fill', - source: { - type: 'geojson', - data: neighborhood - }, - layout: { - visibility: 'none' - }, - paint: { - 'fill-color': { - property: 'jumpBikes', - stops: [ - [0, '#F2F12D'], - [1, '#EED322'], - [2, '#E6B71E'], - [3, '#DA9C20'], - [4, '#CA8323'], - [5, '#B86B25'], - [6, '#A25626'], - [7, '#8B4225'], - [8, '#723122'] - ] - }, - 'fill-opacity': 0.6, - 'fill-outline-color': '#FFF' - } - }); - let popup = new mapboxgl.Popup({ closeButton: false, closeOnClick: false @@ -166,27 +104,16 @@ function loadDcNeighborhoods(bikeshareData, jumpData) { .addTo(map); }); - map.on('mouseenter', `jumpbikes-${neighborhood.properties.OBJECTID}`, e => { - popup.setLngLat(e.lngLat) - .setHTML(`

${e.features[0].properties.NBH_NAMES}

${e.features[0].properties.jumpBikes} JUMP bikes

`) - .addTo(map); - }); - map.on('mouseleave', `cabibikes-${neighborhood.properties.OBJECTID}`, () => { popup.remove(); }); - map.on('mouseleave', `jumpbikes-${neighborhood.properties.OBJECTID}`, () => { - popup.remove(); - }); - }); }; } const toggles = [ - ['Capital Bikeshare Bikes','cabibikes'], - ['JUMP Bikes','jumpbikes'] + ['Capital Bikeshare Bikes','cabibikes'] ]; toggles.forEach(toggle => { @@ -229,12 +156,8 @@ map.on('load', () => { .then(res => res) .catch(err => console.error(err)); - let jumpBike = jumpData() - .then(res => res) - .catch(err => console.error(err)); - - Promise.all([bikeshare, jumpBike]).then(res => { - loadDcNeighborhoods(res[0],res[1]); + Promise.all([bikeshare]).then(res => { + loadDcNeighborhoods(res[0]); }); -}); \ No newline at end of file +}); From 91a43adc7027326a919f14d75ba3a59029d65475 Mon Sep 17 00:00:00 2001 From: Alexandra Ulsh Date: Sun, 22 Dec 2019 13:48:43 +0100 Subject: [PATCH 3/5] Removes Jump elements from index.html --- index.html | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/index.html b/index.html index b73966d..da25954 100644 --- a/index.html +++ b/index.html @@ -27,19 +27,6 @@

Bikes

0
- - From 447b7a1bc0d8d28fb516fdf64fc52e18d60db4bc Mon Sep 17 00:00:00 2001 From: Alexandra Ulsh Date: Sun, 22 Dec 2019 14:36:41 +0100 Subject: [PATCH 4/5] Removes interactivity for single Capital Bikeshare link --- index.html | 6 ++++-- map.js | 40 +--------------------------------------- styles.css | 14 -------------- 3 files changed, 5 insertions(+), 55 deletions(-) diff --git a/index.html b/index.html index da25954..85dcfcf 100644 --- a/index.html +++ b/index.html @@ -11,10 +11,12 @@ - +
-