问题描述
我将带回根据数据库中的用户信息生成的 GD 图像,现在位于查看此图像的页面上.我有以下区域地图,用于由相同类型的查询生成的图像,以创建指向该用户个人资料的链接.但是,数据库中可能有 40000 个用户......无论如何,我所拥有的正在工作,但您可以想象它需要很长时间才能加载.
I'm bringing back a GD Image which is generated from user information in a database, now on the page where this image is viewed. I have the following area map for the image generated by the same sort of query to create a link to that users profile. However, there are a possible 40000 users in the database... anyway, what I have IS working, but as you can imagine it takes a long while for it to load.
<map id="pixel" name="pixel">
<?
$map_x_1 = 0;
$map_y_1 = 0;
$map_x_2 = 5;
$map_y_2 = 5;
$block_num = 1;
while ($map_y_2 <= 1000) {
while ($map_x_2 <= 1000) {
$actual_x_cood = $map_x_1+1;
$actual_y_cood = $map_y_1+1;
$grid_search = mysql_query("SELECT *
FROM project
WHERE project_x_cood = '$actual_x_cood' AND project_y_cood = '$actual_y_cood'") or die(mysql_error());
$block_exists = mysql_num_rows($grid_search);
if ($block_exists == 1) {
echo("<area shape=\"rect\" coords=\"$map_x_1, $map_y_1, $map_x_2, $map_y_2\" href=\"/block/$block_num/\" alt=\"\" title=\"$block_num\" />\n");
} else {
echo("<area shape=\"rect\" coords=\"$map_x_1, $map_y_1, $map_x_2, $map_y_2\" href=\"/block/$block_num/\" alt=\"\" title=\"$block_num\" />\n");
}
$map_x_1 = $map_x_1 + 5;
$map_x_2 = $map_x_2 + 5;
$block_num = $block_num+1;
}
$map_y_1 = $map_y_1 + 5;
$map_y_2 = $map_y_2 + 5;
$map_x_1 = 0;
$map_x_2 = 5;
}
?>
</map>
我正在考虑在 div 的顶部放入一个快速的 jquery 加载屏幕,然后在页面完全加载后将其隐藏,这样看起来更好.但我对它的想法并不是很满意,因为我只想更快地加载它.
I was thinking about just throwing in a quick jquery load screen over the top in a div and then hiding it once the page has fully loaded so it looks nicer. But I'm not really too happy with the idea of it since I would just like to load it faster.
那么有没有更快的方法来做到这一点,也许是 PHP?JS?谢谢!
So is there a quicker way to do it, maybe PHP? JS? Thanks!
推荐答案
你应该捕捉图像地图中的坐标(使用 jquery 很容易)并将其传递给服务器,然后计算用户点击.
you should capture the coordinates in the image map (easy with jquery) and pass it to the server which then calculates the user clicked.
我对一个包含 100 个值 (1-100%) 的比率条做了类似的事情.但它是在原型中完成的,所以代码不会对你有多大帮助.
i did something similar with a rate bar that hat hat 100 values (1-100%). but it was done in prototype so the code wont help you much.
小提示:我必须从绝对点击位置中减去容器的左侧位置.
small hint: i had to substract the left position of the container from the absolute click position.
在 php 和表单中它不是那么灵活但要容易得多.你可以只指定一个输入类型的图像.坐标将作为后变量传递.
in php and forms its not so flexible but far easier. you can just specify an input type image. the coordinates will be passed as post variables.
类似的东西
就够了
这篇关于在图像映射中动态加载 40000 个链接的快速方法(或替代方法)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!