2
2
234234 2342342017-07-03 19:08:05
css
234234 234234, 2017-07-03 19:08:05

Map to svg, how to add text to an element?

You need to make a map like this.
a6c510ed0531462998c402a42bc5a109.png
It turns out that you need to draw regions, and add a label and text to them, I do it in svg because I need to dynamically change the color on hover and turn off some regions (delete text and label).
What are the options for how to build it? In svg, you can’t make nested elements, but I wanted to break everything into groups, region-> name + label + background of the region itself. Maybe there are better svg options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-07-03
@webinar

You can't nest elements in svg

There are groups for that.
so do what stops https://habrahabr.ru/post/230443/
Better not. There is an analogue, for example canvas, but it will be more difficult, in this task
PS: There are a lot of ready-made examples:
https://codepen.io/tag/svg%20map/
https://habrahabr.ru/post/127994/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question