G Web Development Software

cancel
Showing results for 
Search instead for 
Did you mean: 

Hyperlink leaflet

Solved!
Go to solution

Hello,
I was experimenting with the following example: https://rajsite.github.io/webvi-experiments/Leaflet/ and I am attempting to make the popup text a hyperlink. I have tried modifying the function in JavaScript but without success. I am unsure if it is possible to pass a hyperlink as a string using JSLI. Here is the modification I made to the original function:

const createMarker = function (configJSON) {
const config = JSON.parse(configJSON);
const options = {};
if (config.iconUrl !== '') {
options.icon = L.icon({
iconUrl: config.iconUrl,
iconAnchor: L.point(config.iconAnchor.x, config.iconAnchor.y),
popupAnchor: L.point(config.popupAnchor.x, config.popupAnchor.y)
});
}
const marker = L.marker([config.coordinate.latitude, config.coordinate.longitude], options);
if (config.popupText !== '') {
// marker.bindPopup(config.popupText);
const hyperlink = `<a href="https://www.example.com" target="_blank">${config.popupText}</a>`;
marker.bindPopup(hyperlink);
}
return marker;
};

However, it did not work. I considered an alternative where I would retrieve the coordinates from the panel where the popup text appears and make the hyperlink show up, but I also could not find a way to make this work.

Thank you in advance for your assistance.

0 Kudos
Message 1 of 3
(530 Views)
Solution
Accepted by topic author Labmecepel

Using the Maps for WebVI example you can include links in the popup text like follows:

 

MilanR_0-1719927602859.png

 

And they will be rendered in the popup:

MilanR_0-1719927835911.png

 

 


Milan
Message 2 of 3
(513 Views)
I appreciate it once again.
Message 3 of 3
(482 Views)