Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda