Hi everyone! I’m a long time user of Wix for different websites, but fairly new to the coding side.
I have something which is currently working, but i feel i have not gone the best or easiest way about it. I was looking on some suggestions on how you would tackle the following…
You have a map on a website, and information about each district/building. Depending on where you click on the map, you want the corresponding box of information to appear.
This is how i have done it…
The map on my website in a PNG image.
I have overlaid vector shapes onto the map for the areas i want to be clicked, and labelled those as ‘building1, building 2, building 3…’ etc - and added an onClick to each of them.
Upon clicking, the relevant container box will show, with information about that building.
The container box is semi-transparent, contains text, an image, and a button. Each of the container boxes are overlapped ontop of eachother so they will always show in the same spot - and are hidden on load.
That works fine - and it’s something like this:
export function building1_click(event) {
$w('#buildinginfo1').show("fade");
$w('#buildinginfo2').hide("fade");
(‘building1’ refers to the vector shape, and ‘buildinginfo1’ refers to the container box of information)
However, i have 100 different areas on that map…
The way i’ve currently tackled that is to have 100 functions, and each of those functions shows the relevant ‘building info’ and hides ALL the others.
That has resulted in 100 separate functions, each with 1 ‘show’ and 99 'hide’s
When i need to update 1 or 2 of those container boxes (or all of them…?!) i need to basically drag those boxes all over my screen to edit them individually (which is time consuming, and the editor gets quite slow with that many elements) and then align them all again afterwards.
IS that the same way you would tackle this particular instance, or could you recommend an easier way, or a way with less than 5000 lines of code…?