Google-map – based on ID

By Deepika Rao

While implementing google maps – if the ID of the div is ‘map’ the marker gets displayed, if it is something else, it does not.

<div id="map"></div>
<script async defer


function initMap() {
  var myLatLng = {lat: -25.363, lng: 131.044};
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 4,
    center: myLatLng
  var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    title: 'Hello World!'

here if you change the id of the div and even at document.getElementByid from map to anything else it will not work.

is it to be change elsewhere also?

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273