new calculateFeatureDx method which is used by both Canvas and Elements renderers.

This commit is contained in:
ahocevar
2011-10-08 12:26:19 -04:00
parent f2fcb5a95c
commit 281ae3dfe7
2 changed files with 30 additions and 28 deletions

View File

@@ -685,24 +685,15 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
this.hitContext.clearRect(0, 0, width, height);
}
var labelMap = [];
var feature, style, bounds;
var feature, geometry, style;
var worldBounds = (this.map.baseLayer && this.map.baseLayer.wrapDateLine) && this.map.getMaxExtent();
for (var id in this.features) {
if (!this.features.hasOwnProperty(id)) { continue; }
feature = this.features[id][0];
this.featureDx = 0;
if (worldBounds) {
bounds = feature.geometry.getBounds();
var worldWidth = worldBounds.getWidth();
var rendererCenterX = (this.extent.left + this.extent.right) / 2;
var featureCenterX = (bounds.left + bounds.right) / 2;
var worldsAway = Math.round((featureCenterX - rendererCenterX) / worldWidth);
this.featureDx = worldsAway * worldWidth;
}
geometry = feature.geometry;
this.calculateFeatureDx(geometry.getBounds(), worldBounds);
style = this.features[id][1];
this.drawGeometry(feature.geometry, style, feature.id);
this.drawGeometry(geometry, style, feature.id);
if(style.label) {
labelMap.push([feature, style]);
}