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
This commit is contained in:
ahocevar
2008-09-04 08:31:05 +00:00
parent 819dc62d09
commit 4255028c6a

View File

@@ -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;
},