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

109
Visualizações
Extend leaflet with plugin on specific leaflet version

I'm using two different versions of Leaflet in the same project.

For this i installed the latest version of leaflet using an alias ("leaflet-latest"). After importing the library, i use the noConflict function to use both versions.

"L" keyword is used for an old version of Leaflet and "Leaflet" keyword is used for the latest version.

import L from "leaflet-latest";
import "leaflet-hotline";

var Leaflet = L.noConflict();

// L.hotline is defined
// Leaflet.hotline undefined (is not a function)

Everything is working well except when i want to use a plugin with the latest version. Here, i wanted to use the "leaflet-hotline" plugin but when i import it, it extends the global variable L and not "Leaflet".

Any suggestions on how to extend Leaflet and not L?

I tried to solve the problem using this code but it's not a good approach.

import L from "leaflet-latest";
import "leaflet-latest/dist/leaflet.css";
import L_Hotline from "leaflet-hotline";

var Leaflet = L.noConflict();

Leaflet.hotline = L_Hotline.hotline;

In this case, the Leaflet hotline doesn't extends from the good library.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From the docu:

// Pass Leaflet to the plugin.
// Only required to overload once, subsequent overloads will return the same instance.
require('leaflet-hotline')(L);

So it should work like that:

import L from "leaflet-latest";
import "leaflet-latest/dist/leaflet.css";

var Leaflet = L.noConflict();
require('leaflet-hotline')(Leaflet);
about 4 years ago · Juan Pablo Isaza Relatório
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