How do I add a pin to my Google Map from Google Developers Tutorial

BenRichi_

I have been using the Google Developers Tutorial on how to add a map to my website:

https://developers.google.com/maps/tutorials/fundamentals/adding-a-google-map#the_finished_code

I cannot seem to find a way to add a pin to the map, I have used the "centre" function so that the map is centred on the lat and long of the pin, but the pin itself is not visible.

Any way to create a pin at that lat and long?

Korgrue

Just need to instantiate a marker Object and place it at the coordinates:

<!DOCTYPE html>
<html>
  <head>
    <style>
      #map {
        width: 500px;
        height: 400px;
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js"></script>
    <script>
      function initialize() {
        var mapCanvas = document.getElementById('map');
        var myLatLng = {lat: 44.5403, lng: -78.5463};
        var mapOptions = {
          center: new google.maps.LatLng(myLatLng),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(mapCanvas, mapOptions)
        var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        title: 'Hello World!'
  });
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map"></div>
  </body>
</html>

Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how do I add a tabbar on top of my google map?

From Dev

How do hide latitude and longitude from pin on google map

From Dev

How can I click on a pin in a Google map embedded from JavaScript?

From Dev

How to add drop pin in Google Map iOS

From Dev

How to pin on a google map for iOS?

From Dev

Add pin(not marker) to google map Android

From Dev

How to get location from Google Map after dropping Pin over it

From Dev

How do I add google map in angular.js controller?

From Dev

How do I set a cost limit in Google Developers Console

From Dev

Google Developers Console: how do I register a new application?

From Dev

How do I add a legend and a label to my Google Pie Chart?

From Dev

How do I put a text label on a google maps pin?

From Dev

Google map pin title from json array

From Dev

Google map drag pin from inside a div on google map

From Dev

How do I populate Google Map annotations from MVC model

From Dev

How do I uninstall Google Chrome *completely* from my Mac?

From Dev

How do I add data to a Google Sheet from Ruby?

From Dev

How to add pin point on Google Map using package (when you click on a button, it open directly to Google Map App) on android studio

From Dev

How i add my own image or drawing option on google map drawing

From Dev

How do I show annotations on my Google Chart that extracts data from a Google Spreadsheet?

From Dev

How to access google Play Developers console from a Google apps account

From Dev

How do i animate one marker on my google map and leave the rest un-animated?

From Dev

How Can I Drag My Annotation On MKmap View Like Google Pin Drop And Draging:iOS

From Dev

How to add dynamic google map to my website for locations

From Dev

How to add go button and will open google map via my phone

From Dev

How do I add the stock Google search to my own website **with auto-complete**?

From Dev

How do I add my own custom domain to a Google App Engine site in 2016?

From Dev

How do I add both Facebook Login and Email registration to my Google Cloud Endpoints App (Java)?

From Dev

How do I add a Google Cloud Endpoints Module to my Android project in IntelliJ?

Related Related

  1. 1

    how do I add a tabbar on top of my google map?

  2. 2

    How do hide latitude and longitude from pin on google map

  3. 3

    How can I click on a pin in a Google map embedded from JavaScript?

  4. 4

    How to add drop pin in Google Map iOS

  5. 5

    How to pin on a google map for iOS?

  6. 6

    Add pin(not marker) to google map Android

  7. 7

    How to get location from Google Map after dropping Pin over it

  8. 8

    How do I add google map in angular.js controller?

  9. 9

    How do I set a cost limit in Google Developers Console

  10. 10

    Google Developers Console: how do I register a new application?

  11. 11

    How do I add a legend and a label to my Google Pie Chart?

  12. 12

    How do I put a text label on a google maps pin?

  13. 13

    Google map pin title from json array

  14. 14

    Google map drag pin from inside a div on google map

  15. 15

    How do I populate Google Map annotations from MVC model

  16. 16

    How do I uninstall Google Chrome *completely* from my Mac?

  17. 17

    How do I add data to a Google Sheet from Ruby?

  18. 18

    How to add pin point on Google Map using package (when you click on a button, it open directly to Google Map App) on android studio

  19. 19

    How i add my own image or drawing option on google map drawing

  20. 20

    How do I show annotations on my Google Chart that extracts data from a Google Spreadsheet?

  21. 21

    How to access google Play Developers console from a Google apps account

  22. 22

    How do i animate one marker on my google map and leave the rest un-animated?

  23. 23

    How Can I Drag My Annotation On MKmap View Like Google Pin Drop And Draging:iOS

  24. 24

    How to add dynamic google map to my website for locations

  25. 25

    How to add go button and will open google map via my phone

  26. 26

    How do I add the stock Google search to my own website **with auto-complete**?

  27. 27

    How do I add my own custom domain to a Google App Engine site in 2016?

  28. 28

    How do I add both Facebook Login and Email registration to my Google Cloud Endpoints App (Java)?

  29. 29

    How do I add a Google Cloud Endpoints Module to my Android project in IntelliJ?

HotTag

Archive