1

我正在使用 phonegap 创建一个应用程序。在我的页面上,我只是渲染一个图像,然后我使用 Javascript 通过获取要定位的图像大小在其上放置一些映射。如果用户单击该链接,即使您在计算机浏览器上对其进行缩放。

var img = new Image();
var imgheight = 0;
var imgwidth = 0;

//This loads the original image to a variable
var img = new Image();
//define onload function of variable
img.onload = function() {
    imgheight = this.height
    imgwidth = this.width;

    var factorw = $('#'+imgId).width() / imgwidth;
    var factorh = $('#'+imgId).height() / imgheight;
    //these numbers are the default location of the link from the image
    var x1 = factorw * 9;
    var x2 = factorw * 285;
    var y1 = factorh * 150;
    var y2 = factorh * 250;
}
img.src = $('#sampleImg').attr('src');

但是现在当我在设备上调试它时,似乎移动设备具有不同的缩放。当我尝试从设备放大图像并尝试单击链接时,它没有响应。它仅在我单击放置链接的同一位置时才会响应。有人可以帮我弄这个吗?

4

0 回答 0