是否可以增加地图比例但仍然可以有效地悬停? [使用 PHP GD]

发布于 2024-11-06 03:14:16 字数 1760 浏览 0 评论 0原文

我向大家简要介绍一下我的项目。我正在开发一个网络应用程序 仓库管理系统。基本上,我使用 PHP GD 绘制工厂布局图的图像,其中每层都包含货架和托盘。
当您将鼠标悬停在货架或托盘上时,您将能够看到它的细节。

因为使用GD,为了能够绘制每个货架或托盘,需要特定的x和y坐标,以及它的宽度和高度。我使用标签创建区域,以便它可以使用 jquery 进行悬停。

我被要求制作一个具有给定比例的比例图像,但我不知道如何去做。所以我想你们可以帮助我。

在这方面确实需要帮助。

这是我的代码的一些示例,

while($row = mysql_fetch_array($RecordsetZone)){

        $n = substr($row['name'], 4);
    $font = 2;
    $textColor = imagecolorallocate ($source,0,0,0);
    if($row['zonetype']=="Rack"){
        imagerectangle($source, $row['xcord'], $row['ycord'] , $row['width']+($row['xcord']), $row['height']+$row['ycord'], $black);
        imagefilltoborder($source, ($row['xcord'])+1, $row['ycord']+1, $black , $limegreen);
        imagestring ($source, $font, ($row['xcord'])+2, $row['ycord']+5, $n, $textColor);
    }
    elseif($row['zonetype']=="Pallet"){
        imagerectangle($source, $row['xcord'], $row['ycord'] , $row['width']+($row['xcord']), $row['height']+$row['ycord'], $black);
        imagefilltoborder($source, ($row['xcord'])+1, $row['ycord']+1, $black , $dodgerblue);
        imagestring ($source, $font, ($row['xcord'])+5, $row['ycord']+2, $n, $textColor);
    }
}

这是我如何通过从数据库获取 x、y 来绘制图像,

<map name="testmap" id="testmap">
  <?php $RecordsetZone = mysql_query($query, $cakewms) or die(mysql_error()); 
  while($row = mysql_fetch_array($RecordsetZone)){?>
   <area id=<?php echo '"'. $row['name']. '"';?> shape="rect" coords=<?php echo '"'. $row['xcord']. ','.$row['ycord']. 
    ',' . ($row['width']+$row['xcord']) . ',' . ($row['height']+$row['ycord']) . '"';?> href="#" alt="Sun" />
  <?php }?>
</map>

然后使用地图创建悬停区域

,如果我更改比率,我仍然可以悬停在正确的区域吗?

I give you guys a brief detail about my project. I'm working on a web application which is
a warehouse management system. Basically, I'm using PHP GD to draw an image of a factory's layout plan which contain racks and pallets on each floor.
When you hover on a rack or a pallet, you will be able to see the detail of it.

Because using GD, to be able to draw each rack or pallet, it need a specific coordinate of x and y, and also the width and height of it. I use the tag to create area so it could do the hovering with jquery.

I was asked to make a scale image with a given ratio and I wasn't able to figure out how to do it. So I think you guys can help me out.

Really need help on this.

Here are some example of my code

while($row = mysql_fetch_array($RecordsetZone)){

        $n = substr($row['name'], 4);
    $font = 2;
    $textColor = imagecolorallocate ($source,0,0,0);
    if($row['zonetype']=="Rack"){
        imagerectangle($source, $row['xcord'], $row['ycord'] , $row['width']+($row['xcord']), $row['height']+$row['ycord'], $black);
        imagefilltoborder($source, ($row['xcord'])+1, $row['ycord']+1, $black , $limegreen);
        imagestring ($source, $font, ($row['xcord'])+2, $row['ycord']+5, $n, $textColor);
    }
    elseif($row['zonetype']=="Pallet"){
        imagerectangle($source, $row['xcord'], $row['ycord'] , $row['width']+($row['xcord']), $row['height']+$row['ycord'], $black);
        imagefilltoborder($source, ($row['xcord'])+1, $row['ycord']+1, $black , $dodgerblue);
        imagestring ($source, $font, ($row['xcord'])+5, $row['ycord']+2, $n, $textColor);
    }
}

this is how I drew the image by getting the x, y from the database

<map name="testmap" id="testmap">
  <?php $RecordsetZone = mysql_query($query, $cakewms) or die(mysql_error()); 
  while($row = mysql_fetch_array($RecordsetZone)){?>
   <area id=<?php echo '"'. $row['name']. '"';?> shape="rect" coords=<?php echo '"'. $row['xcord']. ','.$row['ycord']. 
    ',' . ($row['width']+$row['xcord']) . ',' . ($row['height']+$row['ycord']) . '"';?> href="#" alt="Sun" />
  <?php }?>
</map>

after that use map to create area for hovering

if I change the ratio, can I still hover on the right area?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三人与歌 2024-11-13 03:14:16

您可以使用特殊的 JQuery 插件 ImageMapster

它允许调整图像映射的大小,同时它们仍然保留在正确标记的活动区域中。

因此,您需要生成一次图像映射,并且重新计算大小调整将是该插件的任务。

它对于使用图像映射的其他情况也很有帮助。

You can use special JQuery plugin ImageMapster.

It allow resize image-maps, while they still stay with correct marked active zones.

So, you will need generate your image-map once, and recounting onresize will be the task of this plugin.

It can also be helpfull in other cases of working with imagemaps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文