#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:
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user