title: Google Maps Places Javascript API
body: <p>I am working on a project that i need to display 2 Google maps places on the same page. Everything works fine when i display only 1 place, as soon as i add the second one, the first stops showing, It will show only 1 at a time, if i disable the first one, it will show the second one. I am a beginner in Javascript, if someone can help me out. Note this has my API key only once, when i had it twice i got an error from google maps. </p>
  
  <pre><code>&lt;HTML&gt;
    &lt;div id="map1" style="height:500px;"&gt;
      &lt;script async defer src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&amp;libraries=places&amp;callback=initMap"&gt;&lt;/script&gt;
      &lt;script&gt;
        function initMap() {
          var map1 = new google.maps.Map(document.getElementById('map1'), {
            center: {
              lat: 40.0527839,
              lng: -74.163964
            },
            zoom: 15
          });
  
          var infowindow = new google.maps.InfoWindow();
          var service = new google.maps.places.PlacesService(map1);
  
          service.getDetails({
            placeId: 'ChIJ-Wn_paSDwYkREENXsJ--cng'
          }, function(place, status) {
            if (status === google.maps.places.PlacesServiceStatus.OK) {
              var marker = new google.maps.Marker({
                map: map1,
                position: place.geometry.location
              });
              map1.setCenter(place.geometry.location);
              map1.addListener('tilesloaded', function() {
  
                infowindow.setContent('&lt;div&gt; &lt;strong&gt;' + place.name + ' ' +
                  place.formatted_address + '&lt;/strong&gt;&lt;/div&gt;' +
                  place.opening_hours.weekday_text[6] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[0] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[1] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[2] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[3] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[4] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[5]);
              });
              infowindow.open(map1, marker);
            }
          });
        }
      &lt;/script&gt;
    &lt;/div&gt;
    &lt;div id="map" style="height:500px;"&gt;
  
      &lt;script&gt;
        function initMap() {
          var map = new google.maps.Map(document.getElementById('map'), {
            center: {
              lat: -33.866,
              lng: 151.196
            },
            zoom: 15
          });
  
          var infowindow = new google.maps.InfoWindow();
          var service = new google.maps.places.PlacesService(map);
  
          service.getDetails({
            placeId: 'ChIJ5zCkBzpFwokRlW13makMfEM'
          }, function(place, status) {
            if (status === google.maps.places.PlacesServiceStatus.OK) {
              var marker = new google.maps.Marker({
                map: map,
                position: place.geometry.location
              });
              map.setCenter(place.geometry.location);
              map.addListener('tilesloaded', function() {
  
                infowindow.setContent('&lt;div&gt;&lt;strong&gt;' + place.name + ' ' +
                  place.formatted_address + '&lt;/strong&gt;&lt;/div&gt;' +
                  place.opening_hours.weekday_text[6] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[0] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[1] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[2] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[3] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[4] + '&lt;BR&gt;' +
                  place.opening_hours.weekday_text[5]);
              });
              infowindow.open(map, marker);
            }
          });
        }
      &lt;/script&gt;
    &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>