In this video we're going to continue by implementing our ad company marker method so I'm still inside
my custom app class.
I'm down here at the bottom.
I'm going to expand the meet the definition.
We're going to create a another marker inside of here.
Now as you might guess the marker code is going to look awfully similar to what we just did.
The only difference is that we're now pulling the latitude and longitude off of a instance of a company
as opposed to a user so I'm going to add in new Google Maps dot marker capital in marker.
We're gonna give this thing an options object.
It's gonna have a map property that is a reference to the map that we want to add the marker to which
will be this dot google map and we also had that position property that's gonna have a latitude coming
from our company that would be company dot location lat and a longitude COMPANY COMING FROM COMPANY
THAT LOCATION dot LNG.
Like so all right.
So I can save this and right away you're going to notice that these two methods right here look awfully
darn similar don't they.
Huh.
That's kind of funny.
Well before we start to obsess over that too much let's make sure we can actually show a marker for
a company.
So I gotta go back over to index dot.
Yes I'm going to comment.
Our import for company right underneath my user I'll create a company
and we can use that company and add it as a marker.
So custom map dot ad company marker.
And I'll pass in my company like so so let's save this flip back over to the browser again and just
make sure we can see our marker.
Yep.
Sure.
Can.
All right.
So we've gotten both our markers to display.
But like I said well our custom map file or our class doesn't have the best format right now.
So this right here this ends the bad code we've written.
So from here on out we're going to discuss how to fix the bad code we have inside of here.
First off let's make sure it's really clear what is bad about this.
So the very bad thing here is that we've got two different methods that very clearly have a ton of duplication
between them.
The only difference is that in this case we are accepting a user in this case we are accepting a company.
Now it sure would be great if we could just take in like one method and say hey as long as you are passing
in something that has like a latitude and longitude everything is going to work out just fine.
And that's exactly what we want to do.
We're going to take these two methods and figure out how to condense them down to just one.
Let's take a quick pause right here.
We're gonna come back the next video and take a look at a couple of diagrams to understand how we're
going to do this by using interfaces and what the implication of it is.
So quick break and I'll see you in just a minute.