Now that we've got our list of points successfully being saved inside of our location context I think
we should attempt to draw that location or essentially that list of points as a Polish line.
Once again on our map that a user can see the track or essentially the points that they have passed
through.
So to do so we can go back to our map.
Dot J.S. file inside up here we've already got a reference to our location context.
So I want to make sure that in addition to pulling off our current location I'm also going to get our
list of locations that we have now stored after doing our recording and then going to make sure that
from that React Native maps library I still have my import for Polish line right there.
So between our list of locations and our Polish line we want to try to draw out our list of coordinates
on the screen.
Now just one little difficulty here.
I want you to recall that the locations array right here has a bunch of different location objects every
location object has a timestamp property and a coords property and inside that coords property is our
longitude and latitude just to make sure that's really clear.
Then throw down a quick council log right here of that locations array.
Then start recording myself once again back over here get one or two points and then I'll flip back
over my terminal and there we go.
So inside of here once again we've got the time stamp property and then also the court's property with
the latitude and longitude when we draw a policy line.
We have to give it an array of latitude and longitude properties inside of objects.
So in other words when we draw this poverty line we're not just going to throw in this big old locations
array.
Instead we're going to have to extract just our coords properties from each of these different locations.
So just a little bit of code we have to write extra I'm going to delete that council log.
Then inside of my map view right after our circle going to place a polish line once again and I'll give
it a coordinates property so inside of here we're going to take a look at our list of different locations
that we have recorded.
You will then map over that array and for every location which I'm going to abbreviate just as Ello
see I'm going to return Ello C dot courts.
So essentially we're going to go through each of those different location objects pull off just the
court's property and return each court's property inside of a brand new Array.
So let's try saving this and seeing how it works.
I'll go back go to try create.
I'm going to start recording and as I do I can immediately see it my track being recorded.
Now of course right now remember we've got this kind of simulated data coming in which means we're always
going up to the top right.
So even though we are definitely drawing each of these separate policy lines on the map correctly it's
going to end up looking just like a very simple straight line right now.
If you are using that data coming out of mock location right here you could add in some advanced logic
to make sure that the longitude and latitude that we generate are not just going off in some singular
direction.
So if you wanted to you can maybe put in some degree of randomness inside of here or maybe you say depending
on whether or not increment is even or odd to increase or decrease the longitude latitude and kind of
get a zig zag like we had previously.
But again I will definitely leave that up to you if you want to add in some more complex randomization
logic inside of your.
Feel free to do so OK.
Well overall I'd say that this is definitely a good improvement.
So let's take a quick pause right here.
Continue in the next video and make sure that we add in the ability to actually save this list of points
that we are recording so quick pause and I'll see you in just a minute.