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

113
Visualizações
LeafLet adding/linking a marker to a line or multiple tooltips for a line

I have the following:

var gcdLines = []; //Geodesic lines
var markers = [];

When I click on my map I add a new line:

var line = new L.Geodesic([gcdLastPoint, [e.latlng.lat, e.latlng.lng]], geodesicOptions);
                line.bindTooltip("brng and rng", { permanent: true }).addTo(mymap).openTooltip();
gcdLines.push(line);

If I press a button and click on the map I get a marker displayed:

        mymap.on('click', function (e) {                    
            if (showLLToggle == true) {
                var latlongstr = DegToDms(e.latlng);
                var marker1 = L.marker([e.latlng.lat, e.latlng.lng], {
                    draggable: false, 
                    title: "Location",
                    riseOnHover: true,
                }).on('click', removeMarker).addTo(markerGroup).bindTooltip(latlongstr, tooltipOptions).openTooltip();

So my markers are in a marker group and my lines are in a separate array/list.

My problem is that when I remove (through a button) the last line added from the gcdLines, the line is removed but the marker is not, and I cannot work out how to link them together so when the line removes the correct marker is also removed. As the last marker added may not be matching marker for the line i cannot just pop() the last marker.

I tried to add the marker information as a 2nd tooltip at the end of the new L.Geodesic line, which worked nicely but when I went to remove the last line it only removed one tool tip (the 2nd one I added). So I assume that I can't have 2 tooltips? Please tell me that I can, if so how do I remove the old tool tip which seems to have be lost in space.

Any ideas on how to link marker to line or have 2 tool tips would be appreciated, or any better ideas.

Thank you!

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