From 4255028c6a509058dcfc674acacd19e62ee14691 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 4 Sep 2008 08:31:05 +0000 Subject: [PATCH] Bringing back the pre-r7652 behavior that allows changing the node type for features that have already been rendered. This is important when re-rendering a feature with a new style, e.g. when switching from externalGraphic to graphicName point symbolizers. r=elemoine (closes #1662) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7944 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Renderer/Elements.js | 32 ++++++++++------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index 9ec048ce16..276af7f454 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -506,44 +506,34 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, { */ redrawNode: function(id, geometry, style, featureId) { // Get the node if it's already on the map. - var currentNode = OpenLayers.Util.getElement(id); - - // Create a new node, or use the current one if it's - // already there. - var newNode; - if (!currentNode) { - var nodeType = this.getNodeType(geometry, style); - newNode = this.createNode(nodeType, id); - } else { - newNode = currentNode; - } + var node = this.nodeFactory(id, this.getNodeType(geometry, style)); // Set the data for the node, then draw it. - newNode._featureId = featureId; - newNode._geometry = geometry; - newNode._geometryClass = geometry.CLASS_NAME; - newNode._style = style; + node._featureId = featureId; + node._geometry = geometry; + node._geometryClass = geometry.CLASS_NAME; + node._style = style; - var drawResult = this.drawGeometryNode(newNode, geometry, style); + var drawResult = this.drawGeometryNode(node, geometry, style); if(drawResult === false) { return false; } - newNode = drawResult.node; + node = drawResult.node; // Insert the node into the indexer so it can show us where to // place it. Note that this operation is O(log(n)). If there's a // performance problem (when dragging, for instance) this is // likely where it would be. - var insert = this.indexer ? this.indexer.insert(newNode) : null; + var insert = this.indexer ? this.indexer.insert(node) : null; if(insert) { - this.root.insertBefore(newNode, insert); + this.root.insertBefore(node, insert); } else { - this.root.appendChild(newNode); + this.root.appendChild(node); } - this.postDraw(newNode); + this.postDraw(node); return drawResult.complete; },