I need to add a hyperlink in a popup which comes from a polygon. The following piece of script shows the text which needs to be a link.

var polygon = L.polygon([
[51.569, -4.144],
[51.568, -4.145],
[51.57, -4.146],
[51.57, -4.145]


polygon.bindPopup(" RTK Survey Area ");

Popup content passed to bindPopup layer method can be any HTML formatted text, which means it can be also a hyperlink.

In your case it could be something like:

polygon.bindPopup('<a href="http://www.mysite.com" target="_blank">RTK Survey Area</a>');

Hyperlink attribute target="_blank" is added so that linked page is opened in new tab/window.

  • Great! Thanks very much!!! – Iliyan Iliev Jan 12 at 14:05
  • If answer helped you solve your problem, it's custom here to accept it so it's clear to other visitors that problem was solved. – TomazicM Jan 12 at 15:08
  • Yes, the answer solved my problem. Thank you!!! – Iliyan Iliev Feb 12 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.