Git Product home page Git Product logo

suzeshardlow / boris_bikes Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 168 KB

An app I created one evening, showing the locations of the Boris Bike stations and available bikes at each. Data is pulled using an AJAX request to the TfL API and shown on a map using the Google Maps API.

Home Page: https://suze.dev/boris_bikes

License: MIT License

CSS 18.85% HTML 14.57% JavaScript 66.59%
javascript html css google-maps-api tfl-api boris-bikes jquery ajax ajax-request

boris_bikes's Introduction

Boris Bikes

Try it here!

A map showing the locations of the Boris Bike (officially called Santander Cycle) stations. Data is pulled from the Transport for London (TfL) API and shown on a map using the Google Maps API.

Introduction

I produced this piece of work in one evening after four weeks of learning JavaScript.

I wanted to create a web page showing a Google Map and then place a marker on the map at the location of each Boris Bike docking station.

I love real-time data so I enjoyed using the TfL API to populate the map.

Build

This project was built using HTML, CSS and JavaScript (including jQuery), along with the TfL API, Google Maps API and styling from Snazzy Maps.

I needed very little in my HTML file as its main purposes were to define the sources for the CSS, JavaScript and Google Map. It also defined the place where the map would be rendered on the page.

I then looked at the TfL API documentation. The TfL API is very useful in that it has thousands of endpoints, however the documentation is quite difficult to follow as a beginner.

The locations of the docking stations are buried in objects within the API. The good news is that the latitude and longitude values are provided for each one, which made it easy to plot them accurately on the map once you have successfully made an AJAX request for the data.

Bonus Functionality

As bonuses, I decided to:

  • Substitute the default Google Maps marker with a custom one - a photo of Boris Johnson's head.
  • Write some logic to have Boris Johnson's head showing in full colour if there is more than one bike at the docking station, or in black and white if there are 0 or 1 bikes at the docking station (thus saving the user a wasted journey).
  • Change the styling of the map to make it look more modern.
  • Add an info window which appears when each head is clicked, showing the name of each docking station, the number of available bikes and the number of spaces.

Future developments

I have included some code to obtain the user's current location and then centre the map on that location. This works if you run the app on your local machine but for it to work on the publicly deployed app, it needs to be running somewhere with SSL.

boris_bikes's People

Contributors

suzeshardlow avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

boris_bikes's Issues

Fix geolocation

This app needs to be deployed somewhere with SSL for the geolocation to work in modern browsers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.