Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!