You can load/parse remote KML via the Google Earth API from any network accessible URL (same server or otherwise) then iterate over the KML objects and programmatically change the styles and the polygon colors.
var href = 'http://code.google.com/'
+ 'apis/earth/documentation/samples/kml_example.kml';
google.earth.fetchKml(ge, href, function(kmlObject) {
if (kmlObject) {
checkObject(kmlObject);
// append KML objects to current view
ge.getFeatures().appendChild(kmlObject);
}
});
function checkObject(kmlObject) {
var type = kmlObject.getType();
if (type == 'KmlDocument' || type == 'KmlFolder') {
var features = kmlObject.getFeatures();
if (features.hasChildNodes()) {
var children = features.getChildNodes();
for (i=0; i < children.getLength(); i++) {
checkObject(children.item(i));
}
}
} else if (type == 'KmlPlacemark') {
// check/set style, change color, etc.
// ...
}
}
Reference: https://developers.google.com/earth/documentation/kml#fetchkml_and_parsekml