I use geoXML to add many polygons and points to my map. I have KML file that is generated dynamically based on changes in associated form.
...
function xmldata(center,zoom,objects) {
var myParser = new geoXML3.parser({map: map, zoom: false});
myParser.parse('http://localhost/private/infofly/misc/nearest.php?zoom=' + zoom + '&coordinates=' + center + '&' + objects + '');
}
...
It works great, but old KML records remain in the map after update. How can i clean objects in map before every new AJAX call?
This should hide all the objects from the previous version:
var myParser=null; // global myParser reference (outside of any function)
function xmldata(center,zoom,objects) {
if (myParser) myParser.hideDocument();
myParser = new geoXML3.parser({map: map, zoom: false});
myParser.parse('http://localhost/private/infofly/misc/nearest.php?zoom=' + zoom + '&coordinates=' + center + '&' + objects + '');
}