As your question matters, mArray [count] .getPosition () is executed before the click event is triggered (but after defining it), this code is not executed until the 'click' occurs. This should work (but not sure why you would like to do it this way):
alert("Tap location in this map"); google.maps.event.addListener(map, 'click', function(event) { mArray[count] = new google.maps.Marker({ position: event.latLng, map: map }); mArray[count].getPosition(); });
source share