Weird label placement in leaflet maps in xarigan slide deck

Hi,

Please consider the R chunks included in the xarigan Rmd setup shown below.

When I execute this code in a vanilla R script in RStudio and hover my mouse cursor on top of the markers in the Viewer tab, the pop-up labels show up right next to the cursor ... that is, right where I would expect them to be.

Now, when one renders the Rmd into a html file and repeats the experience of hovering the mouse cursor on top of the markers, one can see that the labels show at a larger and variable distance from the markers. This issue is even more pronounced in the map I am working on (I can't show) in which the distance between markers and pop-up could be as far a 1 inch.

How can I correct this behavior?

Thank you in advance for your feedback

---
title: "Leaflet in xaringan"
subtitle: "Weird label placement"
author: "pomchip"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

```{r}
library(leaflet)
data(quakes)

quakes$mag <- sprintf('Magntiude: %s', quakes$mag)

# a working path to icon & shadow, hosted on https://cdnjs.com/libraries/leaflet
marker_icon <- makeIcon(
  iconUrl = "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.8.0-beta.0/images/marker-icon.png",
  shadowUrl = "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.8.0-beta.0/images/marker-shadow.png",
)

m <- leaflet(data = quakes[1:20,]) %>%
  addTiles() %>%
  addMarkers(~long,
             ~lat,
             icon = marker_icon,
             popup = ~as.character(mag),
             label = ~as.character(mag))  
```

---

```{r, echo = FALSE, out.width = '100%'}
m
```

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.