The first thing that you want to do, is put in the default coordinates for the map you are using. Note: If you are using the US.txt file, this must be the coordinates of a US city. If you look at line 90 of the code below, you will see that a changed the latitude and longitude from Cambridge, Mass. to Reno, Nev. I chose Reno, because this is where I am located. Look up the coordinates of your city in Google and plug them in to center the map above your home city.
Now, we can create our new marker. Notice that when we create the marker we are setting the position equal to the myLatLng that we created earlier. We are also using the name variable that we created to act as the label for the marker. Go ahead and mess around with the color of the label so that is fits your map design. You will also notice that I added some animation to this marker. I added the DROP animation when the marker is created, so you will see the pin fall from the top top of the screen. Below I also added some animation when the mouse hovers over the marker it will start to BOUNCE. You can mess with all these features by looking at the documentation for animating markers. Also, notice that I set the icon of the image equal to my red push pin image that I created earlier.
Now, you have met all the requirements to complete Mashup. However, I would like you to do a little bit more. There are all sorts of things you can mess around with inside the Google Maps API. One of them is that you can style your map however you want. Take a look at lines 16 to 83. Here I have styled the map with some different colors for roads, highways, and parks. Take a look at the documentation on styling the map and give it some of your own flare.
That is is for Mashup. You have now worked through all the CS50 problem sets. Good Job! Now go out there and create something awesome for your final project. Remember to comment below with any questions and share this post on your favorite social media site. Beginning next week, we will begin working on some real world applications to apply the skills that you have learned. Until then…Happy Programming!