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

518
Views
Cómo lat, lng position desde el componente LeafletJs por livewire

Quiero crear un componente livewire usando un folleto . Cuando el usuario hace clic en el mapa, aparece un marcador y se emite un evento que se puede capturar en JS. Pero quiero enviar esos datos directamente al servidor con livewire. Componente Livewire:

 public $position; protected array $listeners = ['setPosition']; public function setPosition($position) { dd($position); }

componente de la hoja:

 <div wire:model="position" id="map"></div> <script> const map = L.map('map', { center: [35.6892, 51.3890], zoom: 14, minZoom: 12, maxZoom: 14 }); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: 'نقشه © <a href="https://openstreetmap.org">OpenStreetMap</a>' }).addTo(map); var marker = L.marker(); function onMapClick(e) { marker.setLatLng(e.latlng).addTo(map); console.log(Livewire, Livewire.emit('setPosition')); } map.on('click', onMapClick); </script>

Usé Livewire.emit('setPosition') en la última etiqueta del script pero no pasa nada. O en un script separado:

 <script> Livewire.emit('setPosition'); </script>
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!