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

310
Views
Add a button in Leaflet Popup

I am working on a project using React JS and Leaflet. I am trying to call a function using a button inside a leaflet popup.

A and B are the start and end coordinates.

L.polyline([A, B]).addTo(this.state.map).bindPopup('<button onclick="print()">Print</button>')

print = () => {
      // Add some logic here 
      console.log("Prints")
}

The popup is added with the button but function print isn't being called when the button is clicked. The error received is Uncaught ReferenceError: print is not defined at HTMLButtonElement.onclick

Many thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can use jquery like this,

$('button').click(function(){
});

define whatever you want that function to do.

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!