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

150
Views
Integrating Leaflet-Geosearch into Laravel 8 app

I'm trying to display a map and a geosearch input field in a Laravel 8.0 app, using Leaflet and a plug-in called Leaflet-Geosearch. The map displays fine, but I'm having trouble with the geosearch plug-in. The docs say that "something like this should be bound to something like a form or input":

import { OpenStreetMapProvider } from 'leaflet-geosearch';

const form = document.querySelector('form');
const input = form.querySelector('input[type="text"]');

form.addEventListener('submit', async (event) => {
  event.preventDefault();

  const results = await provider.search({ query: input.value });
  console.log(results); // » [{}, {}, {}, ...]
});

I can't figure out how to adapt this for a Laravel app. When I put the above code into the script tags on the form with the "import" statement included, I get an error, "Uncaught SyntaxError: import declarations may only appear at top level of a module." If I put that statement anywhere else, I get "Uncaught ReferenceError: OpenStreetMapProvider is not defined." Where should that import statement go and what form should it take?

I have very limited experience with javascript and with integrating javascript packages into Laravel, so I'd greatly appreciate some help!

about 4 years ago · Juan Pablo Isaza
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!