我有一个非常简单的代码,可以在大 Canvas (2560 * 2560) 上绘制图像,它在 FireFox 中完美运行,但在 IE 中,图像在特定的宽度和高度后(大约在 2200 之后)不会被渲染。 Canvas 确实会响应该区域中的点击事件。
检查代码:
这是 IE9 的错误,还是 Canvas /上下文的宽度和大小的设计限制?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
</head>
<body>
<div style="background-color:#000;width:2560px;height:2560px;">
<canvas id="map" width="2560px" height="2560px"></canvas>
</div>
</body>
</html>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.min.js"
type="text/javascript"></script>
<script>
$(document).ready(function () {
var canvas = document.getElementById("map");
var ctx = canvas.getContext("2d");
var img = new Image();
img.onload = function () {
for (var y = 0; y < 2560; y += 256) {
for (var x = 0; x < 2560; x += 256) {
ctx.drawImage(img, x, y, 256, 256);
}
}
ctx.fillStyle = "rgba(255, 0, 0, 1)";
ctx.fillRect(2400, 2400, 100, 100);
};
img.src = "http://mt1.google.com/vt/lyrs=m@157000000&hl=en&x=9&y=28&z=6&s=Ga";
});
</script>
最佳答案
IE 9.0.8112 在 Windows 7 上似乎没有任何问题。
可能是你电脑的问题,资源太少什么的。
下面这个例子不适合你吗?
郑重声明,拥有较小的 Canvas 并在您想查看更多内容时进行翻译几乎总是一个好主意。这么大的空间干什么?
关于html - Internet Explorer 9 中 Canvas 的奇怪问题, Canvas /上下文的宽度和大小是否有任何限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6547605/