I used something like:
var map;
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 4,
center: {lat: -28, lng: 137.883}
});
map.data.loadGeoJson('https://storage.googleapis.com/maps-devrel/google.json');
}
google.maps.event.addDomListener(window, 'load', initialize);
to load a geojson shape file to the map.data layer of my map. In the shape file, there are a couple of 'feature' classes defining polygons to be drawn on the map. Up until here I have no problems.
Later on though, I want to load another geojson file over the other one (replacing the drawn 'features' on the map). When you just load another file over the other one it just redraws it over the other one. How on earth do you clear the map.data layer of all the features before loading in the new geojson shape file?
I've tried using
map.data.remove(feature)
with a loop, but I can't seem to get all the features from the map.data layer.