1 00:00:00,990 --> 00:00:06,090 In this video we're going to continue by implementing our ad company marker method so I'm still inside 2 00:00:06,090 --> 00:00:07,260 my custom app class. 3 00:00:07,260 --> 00:00:08,600 I'm down here at the bottom. 4 00:00:08,640 --> 00:00:10,890 I'm going to expand the meet the definition. 5 00:00:10,890 --> 00:00:13,340 We're going to create a another marker inside of here. 6 00:00:13,390 --> 00:00:18,570 Now as you might guess the marker code is going to look awfully similar to what we just did. 7 00:00:18,570 --> 00:00:23,580 The only difference is that we're now pulling the latitude and longitude off of a instance of a company 8 00:00:23,640 --> 00:00:34,330 as opposed to a user so I'm going to add in new Google Maps dot marker capital in marker. 9 00:00:34,420 --> 00:00:36,820 We're gonna give this thing an options object. 10 00:00:36,820 --> 00:00:40,930 It's gonna have a map property that is a reference to the map that we want to add the marker to which 11 00:00:40,930 --> 00:00:46,520 will be this dot google map and we also had that position property that's gonna have a latitude coming 12 00:00:46,520 --> 00:00:53,420 from our company that would be company dot location lat and a longitude COMPANY COMING FROM COMPANY 13 00:00:53,740 --> 00:00:55,880 THAT LOCATION dot LNG. 14 00:00:55,910 --> 00:00:58,380 Like so all right. 15 00:00:58,540 --> 00:01:03,890 So I can save this and right away you're going to notice that these two methods right here look awfully 16 00:01:03,890 --> 00:01:05,310 darn similar don't they. 17 00:01:05,310 --> 00:01:05,830 Huh. 18 00:01:05,840 --> 00:01:07,300 That's kind of funny. 19 00:01:07,310 --> 00:01:11,480 Well before we start to obsess over that too much let's make sure we can actually show a marker for 20 00:01:11,480 --> 00:01:12,290 a company. 21 00:01:12,500 --> 00:01:13,820 So I gotta go back over to index dot. 22 00:01:13,850 --> 00:01:16,020 Yes I'm going to comment. 23 00:01:16,040 --> 00:01:20,400 Our import for company right underneath my user I'll create a company 24 00:01:23,800 --> 00:01:26,680 and we can use that company and add it as a marker. 25 00:01:26,750 --> 00:01:31,470 So custom map dot ad company marker. 26 00:01:31,790 --> 00:01:38,830 And I'll pass in my company like so so let's save this flip back over to the browser again and just 27 00:01:38,830 --> 00:01:40,090 make sure we can see our marker. 28 00:01:40,090 --> 00:01:40,430 Yep. 29 00:01:40,510 --> 00:01:40,750 Sure. 30 00:01:40,750 --> 00:01:42,800 Can. 31 00:01:42,820 --> 00:01:43,090 All right. 32 00:01:43,090 --> 00:01:45,400 So we've gotten both our markers to display. 33 00:01:45,580 --> 00:01:52,330 But like I said well our custom map file or our class doesn't have the best format right now. 34 00:01:52,330 --> 00:01:55,250 So this right here this ends the bad code we've written. 35 00:01:55,290 --> 00:01:59,420 So from here on out we're going to discuss how to fix the bad code we have inside of here. 36 00:01:59,470 --> 00:02:03,350 First off let's make sure it's really clear what is bad about this. 37 00:02:03,400 --> 00:02:10,720 So the very bad thing here is that we've got two different methods that very clearly have a ton of duplication 38 00:02:10,720 --> 00:02:11,550 between them. 39 00:02:11,560 --> 00:02:16,640 The only difference is that in this case we are accepting a user in this case we are accepting a company. 40 00:02:16,750 --> 00:02:22,450 Now it sure would be great if we could just take in like one method and say hey as long as you are passing 41 00:02:22,450 --> 00:02:27,320 in something that has like a latitude and longitude everything is going to work out just fine. 42 00:02:27,430 --> 00:02:28,750 And that's exactly what we want to do. 43 00:02:28,780 --> 00:02:33,430 We're going to take these two methods and figure out how to condense them down to just one. 44 00:02:33,490 --> 00:02:34,660 Let's take a quick pause right here. 45 00:02:34,660 --> 00:02:38,140 We're gonna come back the next video and take a look at a couple of diagrams to understand how we're 46 00:02:38,140 --> 00:02:42,370 going to do this by using interfaces and what the implication of it is. 47 00:02:42,580 --> 00:02:44,840 So quick break and I'll see you in just a minute.