Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
How to toggle layers of a map from mapbox in wix/velo?

I have a .html of a map from mapbox that should display in a page on a wix site. I want to change some layers visibility and I followed some tutorials, but I'm receiving this error message that don't show wherer de error is:

TypeError: Cannot read properties of undefined (reading 'getElementById').

Here's my code until now, hope someone can help me!!!

import mapboxgl from 'mapbox-gl';

var isMatch = new Boolean ([true]); 

$w.onReady(function () {
    
mapboxgl.accessToken = 

'pk.eyJ1Ijoiam9hb3BlZHJvdmdhIiwiYSI6ImNreGtqMHZxZTJwcTIzMHB6Y2lnMm00czkifQ.auBfiQMlyayVxRlHCPuPkQ';

const map = new mapboxgl.Map ({

    container: 'Basic',

    style: 'mapbox://styles/joaopedrovga/ckxkj2aon1xh314me52nin8w8'
});

$w('#au').onClick((event) =>{

if(isMatch)

    {
        $w('#img').hide();
        map.setLayoutProperty('water', 'visibility', 'none');
        isMatch = false; 
    }
    else{
        $w('#img').show();
        map.setLayoutProperty('water', 'visibility', 'visible');
        isMatch = true;
    }
});
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!