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:
86
tests/Renderer/Canvas.html
Normal file
86
tests/Renderer/Canvas.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var supported = OpenLayers.Renderer.Canvas.prototype.supported();
|
||||
function test_Renderer_Canvas_constructor(t) {
|
||||
if (!supported) { t.plan(0); return; }
|
||||
t.plan(2);
|
||||
var el = document.body;
|
||||
el.id = "foo";
|
||||
var r = new OpenLayers.Renderer.Canvas(el.id);
|
||||
|
||||
t.ok(r instanceof OpenLayers.Renderer.Canvas, "new OpenLayers.Renderer.Canvas returns Renderer.Canvas object" );
|
||||
t.ok(r.container == el, "renderer container is correctly set");
|
||||
}
|
||||
|
||||
function test_Renderer_Canvas_setextent(t) {
|
||||
if (!supported) { t.plan(0); return; }
|
||||
t.plan(2);
|
||||
var el = document.body;
|
||||
el.id = "foo";
|
||||
var r = new OpenLayers.Renderer.Canvas(el.id);
|
||||
|
||||
var extent = new OpenLayers.Bounds(1,2,3,4);
|
||||
r.resolution = 1;
|
||||
r.setExtent(extent);
|
||||
t.ok(r.extent.equals(extent), "extent is correctly set");
|
||||
t.eq(r.resolution, null, "resolution nullified");
|
||||
}
|
||||
|
||||
function test_Renderer_Canvas_setsize(t) {
|
||||
if (!supported) { t.plan(0); return; }
|
||||
t.plan(2);
|
||||
|
||||
var el = document.body;
|
||||
el.id = "foo";
|
||||
var r = new OpenLayers.Renderer.Canvas(el.id);
|
||||
var size = new OpenLayers.Size(1,2);
|
||||
r.resolution = 1;
|
||||
r.setSize(size);
|
||||
t.ok(r.size.equals(size), "size is correctly set");
|
||||
t.eq(r.resolution, null, "resolution nullified");
|
||||
}
|
||||
|
||||
function test_Renderer_Canvas_getresolution(t) {
|
||||
if (!supported) { t.plan(0); return; }
|
||||
t.plan(2);
|
||||
|
||||
var el = document.body;
|
||||
el.id = "foo";
|
||||
var r = new OpenLayers.Renderer.Canvas(el.id);
|
||||
var map = new OpenLayers.Map("map");
|
||||
r.map = map;
|
||||
var resolution = r.getResolution();
|
||||
t.eq(resolution, map.getResolution(), "resolution matches the map resolution");
|
||||
t.eq(r.resolution, resolution, "resolution is correctly set");
|
||||
}
|
||||
|
||||
function test_Renderer_Canvas_destroy(t) {
|
||||
if (!supported) { t.plan(0); return; }
|
||||
t.plan(5);
|
||||
|
||||
var el = document.body;
|
||||
el.id = "foo";
|
||||
var r = new OpenLayers.Renderer.Canvas(el.id);
|
||||
r.container = document.createElement("div");
|
||||
r.extent = new OpenLayers.Bounds(1,2,3,4);
|
||||
r.size = new OpenLayers.Size(1,2);
|
||||
r.resolution = 1;
|
||||
r.map = {};
|
||||
|
||||
r.destroy();
|
||||
|
||||
t.eq(r.container, null, "container nullified");
|
||||
t.eq(r.extent, null, "extent nullified");
|
||||
t.eq(r.size, null, "size nullified");
|
||||
t.eq(r.resolution, null, "resolution nullified");
|
||||
t.eq(r.map, null, "map nullified");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user