added support for text labels. This also adds getCentroid methods to all
geometries. Thanks crschmidt for the great help with this patch, and thanks to camptocamp for the initial work on this and rcoup for creating the first patches. r=crschmidt (closes #1895) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9262 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -176,7 +176,13 @@ OpenLayers.Renderer = OpenLayers.Class({
|
||||
if (!bounds.intersectsBounds(this.extent)) {
|
||||
style = {display: "none"};
|
||||
}
|
||||
return this.drawGeometry(feature.geometry, style, feature.id);
|
||||
var rendered = this.drawGeometry(feature.geometry, style, feature.id);
|
||||
if(style.display != "none" && style.label && rendered !== false) {
|
||||
this.drawText(feature.id, style, feature.geometry.getCentroid());
|
||||
} else {
|
||||
this.removeText(feature.id);
|
||||
}
|
||||
return rendered;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -196,6 +202,28 @@ OpenLayers.Renderer = OpenLayers.Class({
|
||||
*/
|
||||
drawGeometry: function(geometry, style, featureId) {},
|
||||
|
||||
/**
|
||||
* Method: drawText
|
||||
* Function for drawing text labels.
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* featureId - {String}
|
||||
* style -
|
||||
* location - {<OpenLayers.Geometry.Point>}
|
||||
*/
|
||||
drawText: function(featureId, style, location) {},
|
||||
|
||||
/**
|
||||
* Method: removeText
|
||||
* Function for removing text labels.
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* featureId - {String}
|
||||
*/
|
||||
removeText: function(featureId) {},
|
||||
|
||||
/**
|
||||
* Method: clear
|
||||
* Clear all vectors from the renderer.
|
||||
@@ -231,6 +259,7 @@ OpenLayers.Renderer = OpenLayers.Class({
|
||||
}
|
||||
for(var i=0, len=features.length; i<len; ++i) {
|
||||
this.eraseGeometry(features[i].geometry);
|
||||
this.removeText(features[i].id);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user