7
Well, I’d like to know how to create a site-style map bomnegocio.com
. I don’t know if on that map there is a single image or several grouped images.
Could someone give me a light on how to do that effect?
7
Well, I’d like to know how to create a site-style map bomnegocio.com
. I don’t know if on that map there is a single image or several grouped images.
Could someone give me a light on how to do that effect?
11
First we must create the SVG file, It is necessary to create the states separately, for this I will demonstrate using the image editor GIMP:
Open the GIMP and import a map image from Brazil
Resize the image to the desired size, in the example the size is 600px X 590px
.
Select the first state, in the example selected the Acre, more is indifferent.
Using the magic wand selection tool, select the state.
After selected, click on the menu Select > To vector
Enable the vector window by clicking on the menu Windows > Plug-in dialogs > Vectors. Right-click the vector and export to vector:
Save and open the file using the Notepad++, you will find the code:
<svg xmlns="http://www.w3.org/2000/svg"
width="600" height="590"
viewBox="0 0 432 428">
<path id="seleçao" ...
Change the id
of path
for desired state id, example:
<svg xmlns="http://www.w3.org/2000/svg"
width="600" height="590"
viewBox="0 0 432 428">
<path id="acre" ...
Repeat the process for each state, but in the next one you will only use the code path
generated. This way it will be possible to generate the design SVG code and work with CSS and jQuery and manipulate the map the way you want.
In the example, I created a div
with id="mapa"
and put the code inside this div
:
<div id="mapa">
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="590" viewBox="0 0 432 428">
<path id="acre" data-name="Acre"
fill="none" stroke="black" stroke-width="1"
d="M 40.00,152.22
C 40.00 ..." />
<text x="15" y="160">AC</text>
<path id="amazonas" data-name="Amazonas"
fill="none" stroke="black" stroke-width="1"
d="M 107.4 ..." />
<text x="95" y="105">AM</text>
</svg>
</div>
In the CSS
#mapa svg path {
stroke:#200772; /*cor da borda do estado*/
fill:#4671D5; /*cor do estado*/
cursor:pointer;
}
#mapa svg path:hover {
fill:#be2f33;
stroke:#be2f33;
}
Look at the simple online example, with only two states Jsfiddle, because as I mentioned it is laborious :)
Note: This is a simple example of how to create, you can work to add texts, acronyms and whatever else you want.
After everything is done, how do I link page by page of each state?
@Lucas you can tag <a xlink:href="..."></a>
, or you can open the page you want with jQuery, http://jsfiddle.net/E573B/38/, in the example the state of Acre opens with jQuery and the state of Amazonas with tag <a>
Reliving! it is possible to perform the same "service" only with "drawings" images that have real illustrations and not solid color as the example!
@abfurlan if I could vote with up more than once I would! It helped me a lot!
Browser other questions tagged jquery css
You are not signed in. Login or sign up in order to post.
If you are referring to the home page map, it is done with SVG, look at the source code and you will see.
– Wakim
It has an SVG editing and creation plugin, very good! http:/raphaeljs.com/
– Diego Henrique