gpt4 book ai didi

javascript - 这是什么意思,它有什么帮助?

转载 作者:太空狗 更新时间:2023-10-29 15:09:29 26 4
gpt4 key购买 nike

目前我正在编写一个 Web 应用程序,通过静态 API 从 Google map 导入图像数据 - http://code.google.com/apis/maps/documentation/staticmaps/ - 进入 HTML5 Canvas 。

不幸的是,由于跨域限制,我遇到了无法操作来自 Google map 的像素数据的问题。

但是,我一直在阅读 Doob 先生的这篇博文,他是 Wilderness Downtown 视频 (http://thewildernessdowntown.com) 的幕后推手之一,该视频使用 Canvas 和 Google map - http://mrdoob.com/blog/post/705 - 上面写着:

"An additional challenge was that with you don't have access to the pixel data of images loaded from another domain...However, albeit pixel access is forbidden, context.drawImage() is allowed for copying areas from images hosted on other domains."

我觉得这可能是我的问题的解决方案,因为稍后在帖子中它显示了图像的像素操作,但我不太明白“context.drawImage() 允许复制区域”的确切含义图片托管在其他域上,如果有人能为我澄清一下,那将非常有帮助。

谢谢,

DLiKS

编辑:这是我用来将 Google map 图像绘制到 Canvas 上的代码:

var ctx = document.getElementById('canvas').getContext('2d'); 
var img = new Image();
img.src = 'LINK TO GOOGLE MAPS IMAGE';
img.onload = function(){
ctx.drawImage(img,0,0);
}

图像显示正常,但是当我尝试使用 getImageData 操作 Canvas 上的嵌入图像时,出现安全错误

最佳答案

阅读这篇文章后,我认为您误解了 Mr.doob 所说的话:

"[Jamie] then started researching other ways of drawing the Maps Data in a way that would create the same effect."

没有像素操作,他使用context.drawImage

"...cropping columns from the original image and positioning them one after the other horizontally."

关于javascript - 这是什么意思,它有什么帮助?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4024908/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com