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

285
Visualizações
How to add a search bar on a map using geo portal extention leaflet

I am trying to update a map that is using leaflet. I want to add a geo search bar. For that I installed this extension

geoportal-extensions-leaflet@2.2.2

Now I tried to run this code in the JS.

    var searchCtrl = L.geoportalControl.SearchEngine({});
    this.map.addControl(searchCtrl);

TypeError: L.geoportalControl is undefined

L is refering to :

    const L = require('leaflet');

So now my question is : Does this error means I should do an other "require" for the leaflet geo-portal extensions ? Or does this means that I have installed the extension wrongly or that I did an other mistake ? Edit : I was misunderstanding how to import the library because I had only tried in online tools like codepen in which imports are different.

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

0

What needs to be done is import both leaflet and geoportal-extensions-leaflet.

After the

npm i geoportal-extensions-leaflet

The source of the extention is present inside

node_modules/geoportal-extensions-leaflet

The library should be imported in the JS using :

const Gp = require('geoportal-extensions-leaflet');

And this code will now works but we should refer to Gp in order to access to the geoportal-extensions-leaflet :

var searchCtrl = Gp.geoportalControl.SearchEngine({});
this.map.addControl(searchCtrl);
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