Thank you for the reply, I have been trying to use the marker.setMap(null); but I cannot get it to work. I have to iterate back through each marker and call the setMap on each one. Does this look like I am headed in the right direction? Would I be better off pushing each marker to a new array and then try to iterate back through that in order to remove the markers? The following is in my global JS file:
function showLocations (){
list_coordinate = localStorage.getItem('json_response');
coordsArray = JSON.parse(list_coordinate);
var marker;
myLat = localStorage.getItem('local_geo_lat');
myLong = localStorage.getItem('local_geo_long');
myLatlng = new google.maps.LatLng(myLat,myLong);
map = Appery("map").gmap;
var markersArray=[];
var mapOptions = {
zoom: 5,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
var CreateMarker = function(coordsArray, i){
var marker = new google.maps.Marker({
position: new google.maps.LatLng( coordsArray.lat, coordsArray.long ),
title: coordsArray.name,
map: Appery("map").gmap,
icon:'http://maps.google.com/mapfiles/ms/ic...'
});
markersArray.push(marker);
var infowindow = new google.maps.InfoWindow({content: coordsArray.name});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(Appery("map").gmap,marker);
});
Appery("map").options.mapElement.gmap('addMarker', marker);
};
function removeMarker(coordsArray, i){
var marker = new google.maps.Marker({
position: new google.maps.LatLng( coordsArray.lat, coordsArray.long ),
title: coordsArray.name,
});
marker.setMap(null);
marker.setVisible(false);
Appery("map").refresh();
console.log("removeMarker run");
}
for (var i = 0, j = coordsArray.length; i < j; i++)
removeMarker(coordsArray, i);
for (i = 0, j = coordsArray.length; i < j; i++)
CreateMarker(coordsArray, i);
}
This runs the search fine and I don't get any errors but nothing will delete.