Fireship · @fireship
Location-based Queries with GeoFire and Angular Google Maps
Uploaded August 25, 2017 · Length 5:36
Summary
Implement location-based queries with GeoFire and Angular Google Maps to display items within a certain radius of the user's location.
- angular google maps
- geofire
- location-based queries
- firebase geo fire
- angular google maps tutorial
- location driven app
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
when building a location driven app it's
- 0:02
critical to be able to query data based
- 0:04
on that current user's location in this
- 0:06
episode we're going to use angular
- 0:08
Google Maps along with firebase geo fire
- 0:11
to accomplish this task the app will
- 0:13
first detect the current users location
- 0:15
and then query firebase for any items
- 0:17
within a certain radius of that location
- 0:19
then we'll display those items on the
- 0:21
map along with their distance from the
- 0:23
current user to help us along the way
- 0:25
we're going to use the angular Google
- 0:27
Maps package which includes several
- 0:29
pre-built components and directives for
- 0:31
common Google Maps elements you can
- 0:33
install it with NPM install a GM / Corps
- 0:36
flag save from there you need to go to
- 0:39
the Google cloud platform console and
- 0:41
enable the Google Maps API once enabled
- 0:44
you can generate an API key and then
- 0:47
we'll use that API key in that angular
- 0:49
environment here we already have
- 0:50
firebase configured via angularfire -
- 0:53
and then we'll also add our Google Maps
- 0:55
API key here then we can go over to our
- 0:57
app module and we'll import the
- 0:59
environment as well as the angularfire
- 1:01
module and angular Google Maps then we
- 1:04
can pass a GM or Google Maps API key
- 1:07
when we import it in the module from
- 1:10
here we'll go ahead and create a new
- 1:11
component to handle the map called
- 1:13
Google map then we need to give the map
- 1:15
a CSS style we want it to be full screen
- 1:18
so we'll just do 100 width and height in
- 1:20
the HTML we'll wrap the map in a div so
- 1:23
it only displays if the latitude and
- 1:24
longitude is defined then we can use the
- 1:27
AGM map selector and pass it the
- 1:29
latitude and longitude as input
- 1:31
arguments this will define the center
- 1:34
point of the map then we can nest ajm
- 1:37
markers inside the map and display them
- 1:39
at whichever coordinates we want and if
- 1:41
we want that marker to have a popup
- 1:43
window then we can add the ajm info
- 1:45
window and we can transclude any HTML we
- 1:48
want in here so now we just need to get
- 1:51
the current users location so we can do
- 1:53
this in that component by defining a
- 1:55
Latin longitude variable then during ng
- 1:58
on an it we tap into the global
- 1:59
navigator object and we call get current


