一种快速方式(或替代方式)动态加载图像映射中的40000链接? [英] A fast way (or alternate way) to dynamically load 40000 links in an image map?

查看:131
本文介绍了一种快速方式(或替代方式)动态加载图像映射中的40000链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在在查看该图像的页面上,将数据库中的用户信息生成的GD图像带回。对于通过相同类型的查询生成的图像,我有以下区域图来创建指向该用户配置文件的链接。但是,数据库中有可能有40000个用户......无论如何,我的工作是正常的,但你可以想象它需要很长时间才能加载。

 < map id =pixelname =pixel> 

<?
$ map_x_1 = 0;
$ map_y_1 = 0;

$ map_x_2 = 5;
$ map_y_2 = 5;

$ block_num = 1; ($ map_y_2 <= 1000){

while($ map_x_2 <= 1000){

$ actual_x_cood = $ map_x_1 + 1;
$ actual_y_cood = $ map_y_1 + 1;
$ b $ grid_search = mysql_query(SELECT *
FROM project
WHERE project_x_cood ='$ actual_x_cood'AND project_y_cood ='$ actual_y_cood')或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 \/> \\\
);
$ b} 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 \/> \\\
);

}

$ 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加载屏幕,然后隐藏它一旦页面完全加载,所以看起来更好。但是我对它的想法并不满意,因为我只想加载它。



那么有没有更快的方法来做到这一点,也许PHP ? JS?谢谢!

解决方案

你应该捕获图像坐标(使用jquery很容易)并将其传递给服务器,然后计算用户点击。



我做了一个类似于帽子100值(1-100%)的费率栏。但它是在原型中完成的,所以代码不会对你有太大的帮助。小提示:我必须从绝对点击位置减去容器的左边位置。

p>

在php中,它的表现并不那么灵活,但更容易。你可以指定一个输入类型的图像。坐标将作为后期变量传递。



类似于





就足够了

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>

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.

So is there a quicker way to do it, maybe PHP? JS? Thanks!

解决方案

you should capture the coordinates in the image map (easy with jquery) and pass it to the server which then calculates the user clicked.

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.

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.

something like

will suffice

这篇关于一种快速方式(或替代方式)动态加载图像映射中的40000链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆