Great, well, we're able to build this
map in the previous lecture. So we have
a base map and we have a marker feature here.
Now, this is our code. Now in this
lecture, I'll show you how to add
multiple markers to your map.
And the way to do that is to, one of the ways to
do that is to write this expression
multiple times. So like that, and of course, you
need to change the locations of those markers.
[No audio]
Save the script and execute,
[No audio]
reload, and so you have multiple markers.
So I think as you realize it's
not possible to add multiple markers
with one single method. So with one
single marker method, you need to apply
the method multiple times. However, this
is not very smart to do, and that's the
beauty of programming, you can use a
for loop to actually add multiple markers to
the map. So we're talking about the Python
for loop, which is a one of the
fundamental features of Python. So the
for loop has nothing to do with folium.
Let's say for
[No audio]
for coordinates in,
[No audio]
of course, you would need some sort of
input with the coordinates. I don't
know, let's say like that, let's say a
list of lists. So we have these two
coordinates. Let me copy this,
[No audio]
put it there, and another time and let me
change them to 9, and 7,
[No audio]
and then you'd need to indent this with four
whitespaces. I'll explain this in just a bit.
[No audio]
And in location, you'd need to pass coordinates.
[No audio]
Before explaining the code to you, let me try this alt.
Execute, go to reload, and yep, we still
have the markers there. Of course, the location
changed from the previous one because I
changed the coordinates, here and here.
So how is this working? Well, I'm
iterating with a for loop through this
list of lists. So the items obviously,
of this main list or two other lists,
something items can be anything, in this
case, there are two lists. So what
happens is that, the coordinates
variable in the first iteration, it
will get this first item of the list,
and it will put that small list. So 38.2
-99.1, if you put that list in here.
[No audio]
So basically, this will be
put in here, more or less. That's the
idea. And then in the next iteration
coordinates with fetch, these are the
list and it will put it in here again.
So the marker method will be executed
two times. So the first time it will
generate a marker with this coordinates,
and then in the second iterate
iteration, it will generate a marker
with this coordinates. And that's it.
However, we have a small issue here, the
issue is that, you know, in reality, you
cannot just type the coordinates in a
Python list. Let's say you have 1000
coordinates that you need to map into a
map. And you can, and it's hard to type
them in here or even paste them, copy
and paste them from document in here. So
the solution to that is that, that your
coordinates normally in real life,
they've come as maybe a text file, like
a comma separated text file, CSV, Excel files, etc.
[No audio]
You want to load that file
into Python and then you want to add
the values of that file into the Marker
methods. And you can do that using a for
loop. And how you do that exactly. Well
explain that in the next lecture. Well,
I'll give you a comma separated file
with a lots of coordinates. And we're
going to use that in the script. So I'll
talk to you later.