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

143
Visualizações
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
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