how to remove drawn kml shape from map which is parsed by geoXml3 so that we can parse and draw a newone. I am only seeing method of hideDocument and showDocument on geoXml but it doesn't completely remove.
let filename = "http://localhost:5002/Nevada-2.kml";
let myLocation = { lat: 36.737061, lng: -119.7912549 };
function initialize() {
let lat = 43.502745;
let lng = -116.240845;
myLatLng = new google.maps.LatLng(lat, lng);
let zoom = 12;
let myOptions = {
zoom,
center: myLatLng,
};
// create the map
let map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
let geoXml = new geoXML3.parser({
map: map,
});
geoXml.parse(filename);
google.maps.event.addListenerOnce(geoXml, "parsed", function () {
let exist = false;
for (let i = 0; i < geoXml.docs[0].placemarks.length; i++) {
let placemark = geoXml.docs[0].placemarks[i];
if (placemark.polygon) {
if (
google.maps.geometry?.poly.containsLocation(
new google.maps.LatLng(myLocation),
placemark.polygon
)
) {
exist = true;
break;
}
}
}
if (exist) {
new google.maps.Marker({
map: map,
position: myLocation,
});
console.log("EXIST");
} else {
console.log("Doesn't Exist");
console.log("geoXml: ", geoXml);
}
});
}
remove drawn kml shape from map which is parsed by geoXml3