#706 - map constructor should not add duplicate theme related link nodes to the dom - in the case where there are two maps per page, one should be customizable and the other default - this is now fixed for map + overview map or any other multiple map combo

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3153 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-05-17 16:35:26 +00:00
parent 7871d26df4
commit a80d7f2826
2 changed files with 54 additions and 26 deletions

View File

@@ -199,11 +199,25 @@ OpenLayers.Map.prototype = {
// only append link stylesheet if the theme property is set
if(this.theme) {
var cssNode = document.createElement('link');
cssNode.setAttribute('rel', 'stylesheet');
cssNode.setAttribute('type', 'text/css');
cssNode.setAttribute('href', this.theme);
document.getElementsByTagName('head')[0].appendChild(cssNode);
// check existing links for equivalent url
var addNode = true;
var nodes = document.getElementsByTagName('link');
for(var i=0; i<nodes.length; ++i) {
if(OpenLayers.Util.isEquivalentUrl(nodes.item(i).href,
this.theme)) {
addNode = false;
break;
}
}
// only add a new node if one with an equivalent url hasn't already
// been added
if(addNode) {
var cssNode = document.createElement('link');
cssNode.setAttribute('rel', 'stylesheet');
cssNode.setAttribute('type', 'text/css');
cssNode.setAttribute('href', this.theme);
document.getElementsByTagName('head')[0].appendChild(cssNode);
}
}
this.layers = [];