1
00:00:00,030 --> 00:00:04,799
Great, we were able to build this map in
the previous lecture, so we have a base

2
00:00:04,799 --> 00:00:10,889
map and we have a marker feature here.
This is our code. Now in this lecture

3
00:00:10,889 --> 00:00:16,410
I'll show you how to add multiple
markers to your map. And the way to do

4
00:00:16,410 --> 00:00:23,390
that is to, one of the ways to do that is
to write this expression multiple times

5
00:00:23,390 --> 00:00:31,070
so like that and of course you need to
change the locations of those markers.

6
00:00:31,070 --> 00:00:41,820
Save the script and execute, reload,
and so you have multiple markers.

7
00:00:41,820 --> 00:00:49,219
As you realize it's not possible to add
multiple markers with one single method,

8
00:00:49,219 --> 00:00:54,030
so with one single marker methods.
You need to apply the method multiple.

9
00:00:54,030 --> 00:00:59,579
However this is not very smart
to do, and that's the beauty of

10
00:00:59,579 --> 00:01:05,850
programming you can use a for loop to
actually add multiple markers to the map.

11
00:01:05,850 --> 00:01:12,000
So we're talking about the Python for
loop which is one of the fundamental

12
00:01:12,000 --> 00:01:17,400
features of Python, so the for loop has
nothing to do with Folium. Let's say

13
00:01:17,400 --> 00:01:29,520
for coordinates in, of course you'd
need some sort of input with the

14
00:01:29,520 --> 00:01:38,430
coordinates. I don't know let's say like
that, let's say a list of lists, so we

15
00:01:38,430 --> 00:01:48,149
have these two coordinates. Let me copy
this, put it there, another time. and let

16
00:01:48,149 --> 00:02:01,110
me change them to nine and seven and
then you need to indent this with four

17
00:02:01,110 --> 00:02:06,649
white spaces. I'll explain this
in just a bit.

18
00:02:07,180 --> 00:02:13,050
Then in location you'd need to pass coordinates.
Before explaining the code to you, let me

19
00:02:16,480 --> 00:02:27,820
try this out. Execute, go to reload and yeha,
we still have the markers there. Of course the

20
00:02:27,820 --> 00:02:33,390
location changed from the previous one
because I changed the coordinates in here.

21
00:02:33,390 --> 00:02:38,050
So how is this working?
Well I'm iterating with a for loop

22
00:02:38,050 --> 00:02:45,580
through this list of lists, so the items
of these lists, of this main list are

23
00:02:45,580 --> 00:02:49,300
two other lists, so the items can be
anything, in this case there are two lists.

24
00:02:49,300 --> 00:02:53,950
So what happens is that the
coordinates variable in the first

25
00:02:53,950 --> 00:03:01,540
iteration it will get to this first item
of the list, and it will put that small

26
00:03:01,540 --> 00:03:11,590
list so 32.2 minus 99.1, it will put
that list in here, and so

27
00:03:11,590 --> 00:03:18,000
basically this will be put in here.
More or less. That's the idea.

28
00:03:18,000 --> 00:03:23,200
And then in the next iteration, coordinates
will fetch this other list and it

29
00:03:23,200 --> 00:03:28,590
will put it in here again, and so the
marker method will be executed two times.

30
00:03:28,590 --> 00:03:34,570
And so the first time it will generate a
marker with these coordinate, and then the

31
00:03:34,570 --> 00:03:38,170
second iteration it will
generate a marker with these coordinates.

32
00:03:38,170 --> 00:03:44,019
And that's it. However we have a small
issue here, and the issue is that you know

33
00:03:44,019 --> 00:03:49,750
in reality you cannot just type the
coordinate in a Python list. Let's say

34
00:03:49,750 --> 00:03:54,519
you have a thousand coordinator that
you need to map into a map, and you can,

35
00:03:54,519 --> 00:04:01,209
and it's hard to type them in here,
or even paste them, copy and paste

36
00:04:01,209 --> 00:04:06,790
them from a document in here, so the
solution to that is that your

37
00:04:06,790 --> 00:04:13,090
coordinates normal in real life
come as maybe a text file like a comma

38
00:04:13,090 --> 00:04:18,299
separated text file, CSV, Excel files etc.
You want to load that file into Python

39
00:04:21,340 --> 00:04:28,330
and then you want to add the values of
that file into the marker method and

40
00:04:28,330 --> 00:04:32,410
you can do that using a for loop and
how you do that exactly? Well I'll explain

41
00:04:32,410 --> 00:04:38,200
that in the next lecture where I'll give
you a comma-separated file with lots of

42
00:04:38,200 --> 00:04:43,000
coordinates, and we're going to use that
in this script so I'll talk to you later.

