Create a map with clickable provinces/states using

2019-01-31 00:33发布

I am trying to create an interactive map where users can click on different provinces in the map to get info specific to that province.

Example: http://www.todospelaeducacao.org.br/ http://code.google.com/p/svg2imap/

So far I've only found solutions that have limited functionality. I've only really searched for this using an SVG file, but I would be open to other file types if it is possible.

If anyone knows of a fully functioning way to do this (jQuery plug-in, PHP script, vector images) or a tutorial on how to do it manually please do share.

11条回答
混吃等死
2楼-- · 2019-01-31 01:21

The following code may help you:

$("#svgEuropa [id='stallwanger.it.dev_shape_DEU']").on("click",function(){
    alert($(this).attr("id"));
});

Source

查看更多
男人必须洒脱
3楼-- · 2019-01-31 01:22

I have been using makeaclickablemap for my province maps for some time now and it turned out to be a really good fit.

查看更多
Viruses.
4楼-- · 2019-01-31 01:26

Sounds like you want a simple imagemap, I'd recommend to not make it more complex than it needs to be. Here's an article on how to improve imagemaps with svg. It's very easy to do clickable regions in svg itself, just add some <a> elements around the shapes you want to have clickable.

A couple of options if you need something more advanced:

查看更多
做个烂人
5楼-- · 2019-01-31 01:26

Go to SVG to Script with your SVG the default output is the map in SVG Code which adds events is also added but is easily identified and can be altered as required.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-31 01:30

jQuery plugin for decorating image maps (highlights, select areas, tooltips):

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

Disclosure: I wrote it.

查看更多
等我变得足够好
7楼-- · 2019-01-31 01:31

You have quite a few options for this:

1 - If you can find an SVG file for the map you want, you can use something like RaphaelJS or SnapSVG to add click listeners for your states/regions, this solution is the most customizable...

2 - You can use dedicated tools such as clickablemapbuilder (free) or makeaclickablemap (i think free also).

[disclaimer] Im the author of clickablemapbuilder.com :)

查看更多
登录 后发表回答