Geographic Information Systems Asked on July 22, 2021
I have velow code that works 100% only problem is you have to click on the marker to see what the marker name is. how do i show a label or a tooltip without loosing the html link functionality?
<?php echo $n1; ?>
<?php echo $o1; ?>
<?php echo $p1; ?>
<?php echo $q1; ?>
<?php echo $r1; ?>
<?php echo $s1; ?>
["Office",-25.6641595,28.2375668]
];
var map = L.map('map').setView([-25.890852, 28.090852], 10);
mapLink =
'<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
for (var i = 0; i < planes.length; i++) {
marker = new L.marker([planes[i][1],planes[i][2],planes[i][3]])
.bindPopup(`<a href="${planes[i][3]}" target="_blank" rel="noopener noreferrer">${planes[i][0]}</a>`)
.addTo(map);
}
function onClick(e) {
}
Use the permanent
option when creating a tooltip to keep the marker open.
You can also use the direction:'bottom'
option to position the tooltip below the marker.
https://leafletjs.com/reference-1.7.1.html#tooltip-permanent
.bindTooltip(`${planes[i][0]}`,{permanent:true, direction:'bottom'}).openTooltip()
Correct answer by Dror Bogin on July 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP