My first map

Using an R dataset i want to construct an interactive map with the package leafet

Load Data

library(leaflet)
data(breweries91)
head(breweries91)
## Loading required package: sp
##            coordinates                 brewery                address
## 1 (10.88922, 49.71979)      Brauerei Rittmayer Aischer Hauptstrasse 5
## 2 (11.22899, 49.88405)      Aufsesser Brauerei             Im Tal 70b
## 3  (10.41602, 49.5021)        Brauhaus Doebler            Kornmarkt 6
## 4  (10.9281, 49.27472)    Brauerei Gundel GmbH Noerdlinger Strasse 15
## 5  (11.29193, 49.8619)              Krug-Braeu        Breitenlesau 1b
## 6 (11.50941, 49.79433) Brauerei-Gasthof Herold        Marktstrasse 29
##   zipcode          village  state
## 1   91325        Adelsdorf Bayern
## 2   91347          Aufsess Bayern
## 3   91438    Bad Windsheim Bayern
## 4   91126 Barthelmesaurach Bayern
## 5   91344     Waischenfeld Bayern
## 6   91257      Buechenbach Bayern
##                                                                                    web
## 1   <a href='http://www.rittmayer-aisch.de' target="_blank">www.rittmayer-aisch.de</a>
## 2               <a href='http://www.aufsesser.de' target="_blank">www.aufsesser.de</a>
## 3 <a href='http://www.brauhaus-doebler.de' target="_blank">www.brauhaus-doebler.de</a>
## 4   <a href='http://www.brauerei-gundel.de' target="_blank">www.brauerei-gundel.de</a>
## 5             <a href='http://www.krug-braeu.de' target="_blank">www.krug-braeu.de</a>
## 6             <a href='http://www.beckn-bier.de' target="_blank">www.beckn-bier.de</a>
##   founded
## 1    1422
## 2    1886
## 3    1867
## 4    1887
## 5    1834
## 6    1568
class(breweries91)
## [1] "SpatialPointsDataFrame"
## attr(,"package")
## [1] "sp"

I used the breweries dataset than contains the location (latitude and longitude) of 32 in Franconia; tt’s a SpatialPointsDataFrame.

With next chunks I construct my map, using the clusterOptions I group the breweries depending on the zoom.

myMap <- breweries91  %>% 
        leaflet() %>%
        addTiles() %>%
        addMarkers(popup= paste(breweries91$brewery, breweries91$web, sep = " "), 
                   clusterOptions = markerClusterOptions())
myMap

When you select a single point in the popup you can look the name and the web site of the brewery.