get position of marker in google maps : I am trying to get the current position that mean longitude and latitude of the marker. First a marker becomes created at the users location and when the user click on the map the previous one becomes deleted and a new one becomes created at the users clickpoint. I tried it by my own with `var lat1 = markers.position.lat(); var lng1 = markers.position.lng();` but that havent work and I get with this the error message `Uncaught TypeError: Cannot read property 'lat' of undefined`. How can I get the current position of the marker and save it in a variable?

    var markers = [];
 
        	  // This event listener will call addMarker() when the map is clicked.
        	  map.addListener('click', function(event) {
        addMarkers(event.latLng);            	
        		
              });
              //draw a marker at the position of the user
        	  addMarkers(pos);
        	  // Adds a marker to the map and push to the array.
              function addMarkers(location) {
              var marker = new google.maps.Marker({
                position: location,
                map: map
              });
              markers.push(marker);
            }
          // Sets the map on all markers in the array.
          function setMapOnAll(map) {
          for (var i = 0; i < markers.length; i++) {
            markers[i].setMap(map);
          }
        }
        // Removes the markers from the map, but keeps them in the array.
        function clearMarkers() {
          setMapOnAll(null);
        }
         
              
        	// Deletes all markers in the array by removing references to them.
        	function deleteMarkers() {
        		clearMarkers();
              marker = [];
            }
        	  
              
              