Wednesday, July 6, 2016

Google Maps JavaScript API Tutorial - 2 - Markers

Now that we have our map up and running lets play around with saving different points on our map. In the Google Maps API, these points are called markers.
In order, to set a fixed marker on our map we must first get the position/location in lat/long.
var tribeca = {lat: 40.719526, lng: -74.0089934};
Now that we have saved our location in a variable called tribeca, let's create our marker.
var marker = new google.maps.Marker({
  position: tribeca,
  map: map,
  title: 'My Marker!'
});
Now if we run our html file on our browser, we see our newly placed marker.

To view the full code, please visit here.
Stay tuned for the next lesson: Marker Infowindows

No comments:

Post a Comment