1 00:00:00,000 --> 00:00:02,278 Great, well, we're able to build this 2 00:00:02,279 --> 00:00:04,529 map in the previous lecture. So we have 3 00:00:04,529 --> 00:00:07,193 a base map and we have a marker feature here. 4 00:00:08,123 --> 00:00:10,739 Now, this is our code. Now in this 5 00:00:10,739 --> 00:00:11,879 lecture, I'll show you how to add 6 00:00:11,879 --> 00:00:14,334 multiple markers to your map. 7 00:00:15,248 --> 00:00:19,474 And the way to do that is to, one of the ways to 8 00:00:19,499 --> 00:00:21,959 do that is to write this expression 9 00:00:21,959 --> 00:00:26,053 multiple times. So like that, and of course, you 10 00:00:26,054 --> 00:00:29,576 need to change the locations of those markers. 11 00:00:29,577 --> 00:00:31,746 [No audio] 12 00:00:31,748 --> 00:00:35,436 Save the script and execute, 13 00:00:35,437 --> 00:00:37,621 [No audio] 14 00:00:37,623 --> 00:00:40,527 reload, and so you have multiple markers. 15 00:00:41,045 --> 00:00:43,499 So I think as you realize it's 16 00:00:43,499 --> 00:00:46,139 not possible to add multiple markers 17 00:00:46,529 --> 00:00:50,729 with one single method. So with one 18 00:00:50,729 --> 00:00:52,829 single marker method, you need to apply 19 00:00:52,829 --> 00:00:55,589 the method multiple times. However, this 20 00:00:55,589 --> 00:00:59,219 is not very smart to do, and that's the 21 00:00:59,219 --> 00:01:01,491 beauty of programming, you can use a 22 00:01:01,493 --> 00:01:05,459 for loop to actually add multiple markers to 23 00:01:05,489 --> 00:01:09,149 the map. So we're talking about the Python 24 00:01:09,149 --> 00:01:11,459 for loop, which is a one of the 25 00:01:11,459 --> 00:01:13,919 fundamental features of Python. So the 26 00:01:13,919 --> 00:01:15,749 for loop has nothing to do with folium. 27 00:01:16,949 --> 00:01:18,282 Let's say for 28 00:01:18,283 --> 00:01:21,155 [No audio] 29 00:01:21,157 --> 00:01:24,553 for coordinates in, 30 00:01:24,554 --> 00:01:26,602 [No audio] 31 00:01:26,604 --> 00:01:28,379 of course, you would need some sort of 32 00:01:28,409 --> 00:01:31,919 input with the coordinates. I don't 33 00:01:31,919 --> 00:01:35,459 know, let's say like that, let's say a 34 00:01:35,459 --> 00:01:39,119 list of lists. So we have these two 35 00:01:39,119 --> 00:01:41,928 coordinates. Let me copy this, 36 00:01:41,929 --> 00:01:44,387 [No audio] 37 00:01:44,389 --> 00:01:48,269 put it there, and another time and let me 38 00:01:48,269 --> 00:01:52,820 change them to 9, and 7, 39 00:01:52,821 --> 00:01:57,536 [No audio] 40 00:01:57,538 --> 00:02:01,289 and then you'd need to indent this with four 41 00:02:01,385 --> 00:02:04,748 whitespaces. I'll explain this in just a bit. 42 00:02:04,773 --> 00:02:06,891 [No audio] 43 00:02:06,893 --> 00:02:11,443 And in location, you'd need to pass coordinates. 44 00:02:11,444 --> 00:02:14,457 [No audio] 45 00:02:14,459 --> 00:02:17,154 Before explaining the code to you, let me try this alt. 46 00:02:19,077 --> 00:02:25,815 Execute, go to reload, and yep, we still 47 00:02:25,816 --> 00:02:28,229 have the markers there. Of course, the location 48 00:02:28,229 --> 00:02:30,539 changed from the previous one because I 49 00:02:30,539 --> 00:02:33,419 changed the coordinates, here and here. 50 00:02:34,169 --> 00:02:36,539 So how is this working? Well, I'm 51 00:02:36,569 --> 00:02:39,239 iterating with a for loop through this 52 00:02:39,269 --> 00:02:43,259 list of lists. So the items obviously, 53 00:02:43,829 --> 00:02:46,919 of this main list or two other lists, 54 00:02:47,129 --> 00:02:48,809 something items can be anything, in this 55 00:02:48,809 --> 00:02:50,399 case, there are two lists. So what 56 00:02:50,399 --> 00:02:52,079 happens is that, the coordinates 57 00:02:52,109 --> 00:02:54,659 variable in the first iteration, it 58 00:02:54,659 --> 00:02:58,259 will get this first item of the list, 59 00:02:58,649 --> 00:03:04,199 and it will put that small list. So 38.2 60 00:03:04,229 --> 00:03:08,518 -99.1, if you put that list in here. 61 00:03:08,519 --> 00:03:10,840 [No audio] 62 00:03:10,842 --> 00:03:13,589 So basically, this will be 63 00:03:13,589 --> 00:03:17,369 put in here, more or less. That's the 64 00:03:17,369 --> 00:03:20,339 idea. And then in the next iteration 65 00:03:20,399 --> 00:03:22,469 coordinates with fetch, these are the 66 00:03:22,469 --> 00:03:24,299 list and it will put it in here again. 67 00:03:24,929 --> 00:03:28,049 So the marker method will be executed 68 00:03:28,049 --> 00:03:30,749 two times. So the first time it will 69 00:03:30,749 --> 00:03:34,169 generate a marker with this coordinates, 70 00:03:34,169 --> 00:03:35,519 and then in the second iterate 71 00:03:35,549 --> 00:03:37,469 iteration, it will generate a marker 72 00:03:37,469 --> 00:03:39,449 with this coordinates. And that's it. 73 00:03:39,989 --> 00:03:42,149 However, we have a small issue here, the 74 00:03:42,149 --> 00:03:45,359 issue is that, you know, in reality, you 75 00:03:45,599 --> 00:03:48,149 cannot just type the coordinates in a 76 00:03:48,149 --> 00:03:50,669 Python list. Let's say you have 1000 77 00:03:50,699 --> 00:03:53,189 coordinates that you need to map into a 78 00:03:53,189 --> 00:03:57,209 map. And you can, and it's hard to type 79 00:03:57,209 --> 00:04:00,839 them in here or even paste them, copy 80 00:04:00,839 --> 00:04:03,899 and paste them from document in here. So 81 00:04:03,899 --> 00:04:06,839 the solution to that is that, that your 82 00:04:06,839 --> 00:04:08,729 coordinates normally in real life, 83 00:04:08,729 --> 00:04:12,719 they've come as maybe a text file, like 84 00:04:12,719 --> 00:04:16,710 a comma separated text file, CSV, Excel files, etc. 85 00:04:16,711 --> 00:04:18,750 [No audio] 86 00:04:18,752 --> 00:04:20,339 You want to load that file 87 00:04:20,339 --> 00:04:23,249 into Python and then you want to add 88 00:04:23,639 --> 00:04:26,129 the values of that file into the Marker 89 00:04:26,129 --> 00:04:29,609 methods. And you can do that using a for 90 00:04:29,609 --> 00:04:32,039 loop. And how you do that exactly. Well 91 00:04:32,039 --> 00:04:33,959 explain that in the next lecture. Well, 92 00:04:34,319 --> 00:04:36,989 I'll give you a comma separated file 93 00:04:37,019 --> 00:04:39,749 with a lots of coordinates. And we're 94 00:04:39,749 --> 00:04:41,909 going to use that in the script. So I'll 95 00:04:41,909 --> 00:04:43,264 talk to you later.