.preview私のボタンがクリックされた瞬間に、それは a の各アドレスを見てtextarea、それをプロットします。
.preview前のマーカーと同じポイントの周りに別のマーカーをプロットするだけなので、クリックするたびにマーカーを削除したいと思います。
$('.preview').click(function(){    
setAllMap(null);
var temp_addresses = document.getElementById("gps").value.split("\n");
    for(var i=0;i<temp_addresses.length;i++){
        addresses.push(temp_addresses[i]);
        geocoder.geocode( { 'address': temp_addresses[i]}, function(response, status) {
            geocode_results[i] = new Array();
            geocode_results[i]['status'] = status;
            var top_location = response[0];
            var lat = Math.round(top_location.geometry.location.lat() * 1000000)/1000000;
            var lng = Math.round(top_location.geometry.location.lng() * 1000000)/1000000;
            geocode_results[i]['lat'] = lat;
            geocode_results[i]['lng'] = lng;
            geocode_results[i]['l_type'] = top_location.geometry.location_type;
            marker = markers[i] = new google.maps.Marker({
                icon: mapIcon,
                position: new google.maps.LatLng(lat,lng),
                map: map
            });
        });
    }
});
これにより、次の console.log() が得られますReferenceError: setAllMap is not defined
やってみmarker.setMap(null);たけど戻ってきたTypeError: marker.setMap is not a function
助けていただければ幸いです
編集。
    var marker = [];
    var addresses = new Array();
    var geocode_results = new Array();
    function setAllMap(map) {
       for (var i = 0; i < marker.length; i++) {
          marker[i].setMap(map);
       }
    }
    $('.preview').click(function(){    
setAllMap(null);
var temp_addresses = document.getElementById("gps").value.split("\n");
    for(var i=0;i<temp_addresses.length;i++){
        addresses.push(temp_addresses[i]);
        geocoder.geocode( { 'address': temp_addresses[i]}, function(response, status) {
            geocode_results[i] = new Array();
            geocode_results[i]['status'] = status;
            var top_location = response[0];
            var lat = Math.round(top_location.geometry.location.lat() * 1000000)/1000000;
            var lng = Math.round(top_location.geometry.location.lng() * 1000000)/1000000;
            geocode_results[i]['lat'] = lat;
            geocode_results[i]['lng'] = lng;
            geocode_results[i]['l_type'] = top_location.geometry.location_type;
            marker = markers[i] = new google.maps.Marker({
                icon: mapIcon,
                position: new google.maps.LatLng(lat,lng),
                map: map
            });
        });
    }
});