Skip to content

Commit

Permalink
createPopover
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandercar-vt committed Jun 20, 2024
1 parent 61fb4f5 commit b41996a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import './styles/index.css'
* Regular imports
*/
import {
LeafletMouseEvent,
map as createMap,
geoJSON,
latLng,
Expand Down Expand Up @@ -76,16 +77,13 @@ await Promise.all(
popover.innerHTML = `<b>${dateStr}</b><br><i><b>Distance: ${distanceStr}mi</b></i><br><i>Total Ascent: ${ascentStr}ft</i>`

let layerPopup: Popup | null
feature.on('mouseover', function (e) {
const createPopover = function (e: LeafletMouseEvent) {
layerPopup = popup().setLatLng(e.latlng).setContent(popover.outerHTML).openOn(map)
feature.setStyle(lineStyleHovered)
feature.bringToFront()
})
feature.on('click', function (e) {
layerPopup = popup().setLatLng(e.latlng).setContent(popover.outerHTML).openOn(map)
feature.setStyle(lineStyleHovered)
feature.bringToFront()
})
}
feature.on('mouseover', createPopover)
feature.on('click', createPopover)
feature.on('mouseout', function () {
if (layerPopup) {
map.closePopup(layerPopup)
Expand Down

0 comments on commit b41996a

Please sign in to comment.