【问题标题】:Bring up part of image onmouseover在鼠标悬停时调出部分图像
【发布时间】:2014-10-19 14:38:09
【问题描述】:

我正在实现 Web 应用程序。现在我有一个州的MAP image,我通过计算该地区的坐标来划分该地区的每个地区。

以下是我正在使用的 MAP 图片:

以下是坐标点:

<area id="puneArea" shape="poly" coords="154,250,157,250,158,251,160,251,162,253,165,253,167,254,170,254,173,254,174,255,175,257,175,258,177,260,178,262,179,263,182,264,184,264,187,266,190,267,192,267,196,267,198,267,199,268,199,270,198,271,198,274,195,275,192,276,191,278,190,279,190,283,190,284,191,287,192,288,195,291,196,293,198,296,201,297,203,301,204,302,207,302,208,302,209,306,211,310,213,312,213,312,215,314,216,314,217,316,219,318,219,321,220,322,221,325,221,326,222,329,224,330,224,331,225,334,226,337,226,338,228,339,229,339,229,339,232,338,232,337,232,335,234,335,237,335,237,335,238,338,238,339,238,340,238,342,241,343,242,344,243,346,245,347,245,348,246,350,246,354,246,358,247,359,249,359,250,358,251,358,254,358,255,358,257,358,258,356,259,358,262,359,263,359,266,361,266,364,268,364,270,364,271,367,272,368,274,369,275,371,275,372,276,373,274,375,271,376,267,379,266,381,266,384,266,384,266,385,268,385,270,385,271,388,270,389,268,390,262,390,260,390,258,389,255,389,253,388,250,386,249,384,242,382,238,381,233,380,228,377,224,377,221,377,216,377,213,376,211,376,208,375,205,375,204,375,203,373,200,373,194,373,191,373,190,373,187,372,184,371,182,369,179,369,175,368,173,367,169,365,166,365,162,365,163,367,163,371,162,372,161,373,158,375,158,376,154,377,153,377,146,377,144,377,141,377,137,377,136,375,136,373,136,371,137,368,140,367,139,364,133,364,131,361,129,361,129,359,129,356,131,355,127,354,125,354,123,352,120,348,120,347,118,342,116,337,116,337,116,334,115,331,114,329,112,326,112,323,112,321,112,320,112,318,112,316,114,313,114,310,115,309,115,308,116,304,116,304,116,301,119,299,120,296,121,295,123,292,125,289,128,288,131,285,131,284,131,283,131,281,131,278,131,275,131,275,131,270,132,270,133,270,136,268,137,267,137,267,140,267,141,266,142,264,144,260,144,259,144,258,144,258,144,258
" href="pune.html" alt="Sun">

当我点击Pune district 区域时,我能够显示新页面。 但是现在我想,当鼠标悬停在 Pune 区域时,Pune 区域会弹出,看起来像“This is pune area”。

那么我怎样才能在 javascript 或 jquery 中做到这一点。

任何帮助将不胜感激。 谢谢

【问题讨论】:

  • 问题不够清楚,请说明您到底想做什么。
  • @ProllyGeek -实际上,当我将鼠标悬停在特定区域区域时,例如“浦那区域”。只有浦那地区的部分会被提出一些,所以看起来这是“浦那地区”
  • 你是什么意思提出,比如工具提示?文本 ?图片 ?还是什么?
  • @ProllyGeek - 启动意味着,当我将鼠标悬停在特定区域上时,它会像这样填充你被选中的区域。

标签: javascript jquery css 3d


【解决方案1】:

在您的情况下,您应该将地图视为矢量或 SVG,然后您可以填充区域,或突出显示它,添加描边等,这可以使用 jvectormaps 完成

有很好的支持和易于使用,你可以从这里开始:

http://jvectormap.com/tutorials/getting-started/

P.S : 你可以添加你自己的自定义地图来使用。

【讨论】:

    【解决方案2】:

    如果您的意思是要突出显示区域 onMouseOver 事件,请检查这些链接,

    http://www.outsharked.com/imagemapster/

    Using jQuery to highlight a div, whilst greying out others

    如果您要缩放、增长或收缩,您可以使用 jquery animate

    http://docs.jquery.com/Effects/animate.

    还请查看以下链接,

    jquery 规模http://api.jqueryui.com/scale-effect/

    Is there a way to grow/shrink an image on hover using Jquery?

    【讨论】:

      【解决方案3】:

      您可以为每个区域标签创建一个 onmouseover 事件,并将区域名称作为 javascript 函数的参数传递,如下所示。

      <area shape="rect" coords="0,0,82,126" alt="Sun" href="pune.html" onmouseover="PopName('Pune')">
      

      您可以使用 region 参数来显示您想要的任何内容。我刚刚弹出了一个警告框供您参考。

      <script>
      function PopName(x) {
         alert("This is" + x);
      }
      </script>
      

      要突出显示 Pune 区域,您可以添加动态 css。

      以下是示例代码。您可以根据您的网络需求即兴创作。

      <body>
      <p id="p1" onmouseover="change()"></p>
      <img src="http://i.stack.imgur.com/u5F7E.png" usemap="#newname">
      <map name="newname">
      <area shape="rect" coords="0,0,82,126" alt="Sun" href="index.html" onmouseover="PopName('Mumbai')">
      </map>
      <div id="pop"></div>
      </body>
      <script>
      function PopName(x) {
         document.getElementById("pop").innerHTML = '<img src="http://www.world-guides.com/images/mumbai/mumbai_city_map.jpg">';
         document.getElementById("p1").innerHTML = "This is " + x;
      }
      </script>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-26
        相关资源
        最近更新 更多