Fireship · @fireship

Realtime Maps with Mapbox + Firebase + Angular

Uploaded July 28, 2017 · Length 6:48

Realtime Maps with Mapbox + Firebase + Angular

Summary

build real-time maps with mapbox, angular, and Firebase by creating a map that updates in real-time with user input and GPS coordinates

  • mapbox api
  • angular 4
  • firebase database
  • real-time maps
  • gps coordinates
  • geojson spec

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    realtime map features are part of some

  2. 0:02

    of the most successful apps in the world

  3. 0:04

    such as Uber ways and Pokémon go in this

  4. 0:07

    episode I'm going to show you how to

  5. 0:09

    start building your own real-time map

  6. 0:10

    features using the mapbox API with

  7. 0:13

    angular 4 on the front end and Firebase

  8. 0:15

    on the back end the demo you're looking

  9. 0:17

    at here allows users to post messages on

  10. 0:19

    the map that are associated with

  11. 0:21

    specific GPS coordinates then the user

  12. 0:24

    can click on the message and fly to

  13. 0:25

    wherever those GPS coordinates happen to

  14. 0:27

    be the important thing to notice here is

  15. 0:30

    that the data in Firebase and the map

  16. 0:32

    are staying in sync in real time so any

  17. 0:34

    user observing this map will have access

  18. 0:36

    to the latest data as soon as it's saved

  19. 0:38

    to the Firebase database before we get

  20. 0:40

    into the code I want to share a helpful

  21. 0:42

    tutorial from West Doyle he spends a

  22. 0:44

    full hour building a RunKeeper inspired

  23. 0:46

    angular 4 app which is a great resource

  24. 0:49

    if you're working with mapbox you can

  25. 0:50

    find the link in the description below

  26. 0:53

    the first step is to sign up for a free

  27. 0:55

    mapbox account and then retrieve your

  28. 0:57

    API access token during the initial

  29. 1:00

    setup mapbox should give you a link to

  30. 1:02

    the CSS that you can include in the

  31. 1:04

    index.html file and then you'll want to

  32. 1:08

    add your access token to your

  33. 1:10

    environment file then you can run npm

  34. 1:12

    install mapbox DGL mapbox has some good

  35. 1:16

    default Maps out of the box but you can

  36. 1:17

    customize them to an infinite number of

  37. 1:20

    combinations in this case I'm using the

  38. 1:22

    cogram app to mimic the color pattern in

  39. 1:24

    an image then you can use the mapbox

  40. 1:27

    editor to customize all the finer

  41. 1:29

    details Within in the map one thing

  42. 1:30

    that's really important when working

  43. 1:32

    with any geolocation data is to make

  44. 1:34

    sure it follows a consistent format in

  45. 1:36

    this example we're going to create a

  46. 1:37

    typescript interface to ensure that it

  47. 1:40

    follows the geojson spec geolocation

  48. 1:43

    data is often shared between multiple

  49. 1:45

    platforms so we want to make sure our

  50. 1:47

    app is following the same spec that

  51. 1:48

    every other API is going to follow the

  52. 1:51

    most important aspect here is the

  53. 1:52

    geometry which is just the GPS

  54. 1:54

    coordinates of a given location we're

  55. 1:57

    also going to create a feature

  56. 1:58

    collection class which is is part of the