Well we can draw to a series of points on our map which is definitely great but of course we probably
won't show the user's actual location.
So in this video we're going to start to get a better idea of how to figure out the user's current location
in the world and then eventually show it on our map.
Let's first begin with a quick discussion about a library that we're going to use to handle all this
location stuff.
So we're going to use a library called Expo dash location.
Now unlike some the other libraries that we've used from Expo throughout this course Expo location is
not installed inside of our project by default.
So we do need to make sure that we install it separately a couple notes here on how we're going to use
this library before we can ever actually track the user's location in the world.
We need to ask the user for permission.
Now this is not just like kind of us being nice and saying hey we're going to try to track your location.
No instead we're going to tell the operating system that the phone is running so either IOW or android
that we intend to track the user's location when we do that the IOW device or Android device is going
to prompt the user and say hey this application is trying to track your location.
Do you approve it or reject it if a user rejects that tracking.
Well we need to make sure that we handle that in some way.
But if user approves it that's great.
We can then start to track the user's location and we're good to go when we start tracking the user's
location with Expo location.
There's two different forms of tracking we can use either foreground or background foreground tracking
is a reference to saying that we're going to track the user's location anytime our application is visible
on the screen.
The nice thing about foreground tracking is that it's really easy to set up and use.
It just takes one or two lines of code background checking on the other hand allows us to track the
user's location at all times even if the user is not actively using our application or even if the device
is locked.
Now the downside to background location is that it uses considerably more battery power because in general
we're just tracking the user for longer.
It's also a lot more complicated to set a background location tracking because it involves running some
amount of javascript code when our application is not actually up on the screen so for our application
we're going to initially focus on using foreground location tracking just because like I said a little
bit easier to get started with.
So we can get a better understanding of exactly what's going on now lasting one dimension is that we
need to be very much aware of whenever we are tracking the user's location because it does use some
amount of battery power.
This is going to be very relevant for our application in particular let me tell you why.
So when a user first comes to the track create screen we want to show the user's location in the world.
So the instant they come to the screen we need to immediately start tracking their location even if
they do not tap on that record button.
Now the key there is that when the user comes to the screen yes we're going to start tracking them.
But if the user navigates a way to like the account screen or the track list without hitting record
we need to then make sure that we stop tracking their location because their user is not actively trying
to recording things so there's no purpose to us burning some battery power.
However if a user comes to the screen and then hits record and then navigates away we definitely do
want to continue to track their location.
So in other words there's going to be some different scenarios here that we need to think about very
carefully and decide whenever a user navigates away from the screen whether or not we want to continue
tracking their location all right.
That's some high level things we need to be aware of as we go through this process before we take a
break.
We're going to install Expo location very quickly so at our terminal we're going to run this command
to install the library.
Now you'll notice that we're not using a classic npm install here.
That's because the version of Expo location we get depends upon the version of React Native.
And expo that we are using.
So by installing Expo location with Expo CSI we're going to make sure that we get the correct version.
All right.
So I'll fall back on my terminal and inside my project directory I'll do it.
MP exposed the ally install Expo location like so and that's pretty much it.
I'm going to let this do its thing.
When we come back the next video we're gonna start to wire up some code inside of our project to make
sure that we can ask users for permission to track their location.