CSS 交互式地图 - 重叠的县在悬停时改变颜色

发布于 2024-09-24 07:00:38 字数 442 浏览 4 评论 0原文

我被要求创建一张英国地图,描绘各个县。一旦将县悬停在上面,它们就会改变颜色,点击它们就会进入中间页面。闪存也不是一个选择。

通常这不会成为问题,但由于县的形状奇特,这些可以悬停的区域将严重重叠,这意味着任何被另一个县悬垂覆盖的县都将无法悬停。

知道我见过一个类似的事情没有重叠问题的例子,但我根本找不到它。有谁知道我如何做到这一点而不重叠成为最终用户的大问题?

我没有任何代码可以展示,因为我还没有开始研究它,我只是知道这会很头痛。我将使用的地图很可能与此相同: http://proofs10.issl.co.uk/images/contact-map.jpg 正如您所看到的,如果我将元素覆盖在每个县上,就会产生问题。

I've been asked to create a map of the UK, depicting counties. Once the counties are hovered, they change colour, and clicking on them goes to an intermidiary page. Flash is also not an option.

Usually this wouldn't be a problem but because of the odd shapes of the counties, these areas that can be hovered are going to overlap quite heavily, which means any county being covered by the overhang from another county won't be hoverable.

I know I've seen an example of a similar thing being done without the overlapping problem but I can't find it at all. Does anyone have any ideas as to how I might do this without overlapping becoming a big problem for the end user?

I don't have any code to show as I've not begun work on it yet, I just know it's going to be a headache. The map I'll be using is mostly likely going to be the same as this one: http://proofs10.issl.co.uk/images/contact-map.jpg and as you can see if I overlay elements over each county that's going to create a problem.

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

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

发布评论

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

评论(2

梦与时光遇 2024-10-01 07:00:38

有了 flash 就不可能了,你唯一的选择就是 javascript。我使用了jquery插件:

http://davidlynch。 org/blog/2008/03/maphilight-image-map-mouseover-highlighting/

该文档非常好。一旦你掌握了它的窍门,一切就变得轻而易举了。祝你好运。

With flash out of the question your only other option is javascript. I have used a jquery plugin:

http://davidlynch.org/blog/2008/03/maphilight-image-map-mouseover-highlighting/

The documentation is pretty good. Once you get the hang of it it's a breeze. Good luck.

洒一地阳光 2024-10-01 07:00:38

可能有点矫枉过正,但 OpenLayers 是一个跨浏览器 JavaScript 库,可让您在网页上放置可缩放、可拖动的交互式地图。可以使元素在悬停时突出显示并在单击时执行某些操作。如果您只想要固定地图,则可以限制缩放和平移。

您必须以合适的矢量格式获取县地图(GML 效果很好)。

Probably slightly overkill, but OpenLayers is a cross-browser JavaScript library that lets you put zoomable, draggable interactive maps on your web page. Elements can be made to highlight on hover and do something on click. You can restrict the zooming and panning if you just want a fixed map.

You'd have to get your county map in a suitable vector format (GML works well).

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