Add support for a Canvas renderer. This renderer will allow for some new
capabilties in OpenLayers Vector drawing, including: * Vector support for iPhone, Safari 2.x series browsers * Improved performance of dragging the map with a large number of geometries. The Vector layer default renderer order is now SVG, VML, Canvas, so browsers with Canvas support and no SVG or VML will be able to draw vectors. The Canvas layer has a number of limitations: getFeatureFromEvent is much slower than the other types of layer, and any change to any feature requires a redraw of the entire canvas. Because Canvas is typically a pretty fast drawing implementation, the latter is less problematic than it might otherwise be. r=pagameba,fred, with glances from a couple other people. (Closes #1512) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7862 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -145,7 +145,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
* the first renderer which returns true for the 'supported()'
|
||||
* method will be used, if not defined in the 'renderer' option.
|
||||
*/
|
||||
renderers: ['SVG', 'VML'],
|
||||
renderers: ['SVG', 'VML', 'Canvas'],
|
||||
|
||||
/**
|
||||
* Property: renderer
|
||||
@@ -381,6 +381,11 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
if (!this.drawn || zoomChanged) {
|
||||
this.drawn = true;
|
||||
for(var i=0, len=this.features.length; i<len; i++) {
|
||||
if (i != (this.features.length - 1)) {
|
||||
this.renderer.locked = true;
|
||||
} else {
|
||||
this.renderer.locked = false;
|
||||
}
|
||||
this.drawFeature(this.features[i]);
|
||||
}
|
||||
}
|
||||
@@ -402,6 +407,11 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
var notify = !options || !options.silent;
|
||||
|
||||
for (var i=0, len=features.length; i<len; i++) {
|
||||
if (i != (features.length - 1)) {
|
||||
this.renderer.locked = true;
|
||||
} else {
|
||||
this.renderer.locked = false;
|
||||
}
|
||||
var feature = features[i];
|
||||
|
||||
if (this.geometryType &&
|
||||
@@ -463,6 +473,20 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
var notify = !options || !options.silent;
|
||||
|
||||
for (var i = features.length - 1; i >= 0; i--) {
|
||||
// We remain locked so long as we're not at 0
|
||||
// and the 'next' feature has a geometry. We do the geometry check
|
||||
// because if all the features after the current one are 'null', we
|
||||
// won't call eraseGeometry, so we break the 'renderer functions
|
||||
// will always be called with locked=false *last*' rule. The end result
|
||||
// is a possible gratiutious unlocking to save a loop through the rest
|
||||
// of the list checking the remaining features every time. So long as
|
||||
// null geoms are rare, this is probably okay.
|
||||
if (i != 0 && features[i-1].geometry) {
|
||||
this.renderer.locked = true;
|
||||
} else {
|
||||
this.renderer.locked = false;
|
||||
}
|
||||
|
||||
var feature = features[i];
|
||||
|
||||
if (notify) {
|
||||
|
||||
Reference in New Issue
Block a user