Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
Is there a way to add mapbox hover popups without needing to scrap this code?

Is it possible to add a hover for the pin popups without needing to create this code from scratch? At the moment I can click the markers and the popup displays.

Is there a way to add a mousenter for the popups to my existing code?

if($('#map').length) {
    const geoLocation = $('.graphic_map').data('json');
    const mapCenterPos = $('.graphic_map').data('center-pos');
    const mapZoom = $('.graphic_map').data('zoom');

    mapboxgl.accessToken = 'token goes here';

    var map = new mapboxgl.Map({
        container: 'map', 
        style: 'mapbox://styles/mapbox/light-v10', 
        center: mapCenterPos,
        zoom: mapZoom ? mapZoom : 14 
    });

    map.addControl(new mapboxgl.NavigationControl());

    geoLocation.features.forEach(function (marker) {
        var el = document.createElement('div');
        el.className = `marker ${marker.status}`;

            new mapboxgl.Marker(el)
            .setLngLat(marker.geometry.coordinates)
            .setPopup(new mapboxgl.Popup({ offset: [130, -15] }).setHTML(
                ` 
                <div class="tooltip">
                    <div class="tooltip__thumbnail" style="background-image:url('${marker.properties.image}')"></div>
                    <div class="tooltip__text">                    
                        <p>${marker.properties.title.replace('~',"'")}</p>
                        <div>${marker.properties.description}</div>
                        <a class="tooltip__view" href="${marker.properties.link}">View</a>
                    </div>
                </div>
                `
                
            )
            )
            .addTo(map);


        const legendCheckbox = $('.graphic_map__legends').find(`[name=${marker.status}]`);
        $(legendCheckbox).parent().click(function() {
            $('.graphic_map__legend').removeClass('active');
            $(this).addClass('active');
            $('.graphic_map__legend input').prop('checked', false);
            $(this).children('input').prop('checked', true);
            if(marker.status == 'all') {
                $('.graphic_map__map .marker').show();
            } else {
                $('.graphic_map__map .marker:not(.all)').hide();
                $(`.graphic_map__map .marker.${marker.status}`).show();

            }
        });
    });
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda