I've built a for loop to test a set of locations and when true send lat/long values to a function to create markers. My problem is the marker moves, but doesn't make additional markers. I'm not clear on why this happens because I would think since I'm making a new instance variable every time the addMarker function is called, that I would get another marker on the map. Any help is appreciated. Thanks.
function addMarker(x, y) {
var myLatLng = {
lat: parseFloat(x),
lng: parseFloat(y)
};
console.log(myLatLng);
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 6,
center: myLatLng
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'hello world'
});
markers.push(marker);
marker.setMap(map);
}