6.8 Interative map with Leaflet

Code
dg = d %>% 
  filter(state == 'CT') %>%
  mutate(label = paste0(network       , '<br>', 
                        station.name  , '<br>',
                        street.address, '<br>', 
                        city          , ', ', 
                        state         , ' ', 
                        zip           , '<p>', 
                        'Level 2: ', lev2, '<br>',
                        'Level 3: ', lev3))
head(dg,2)
  fuel.type.code                                      station.name
1           ELEC                                Whole Foods Market
2           ELEC Propark America - Omni Hotel Chapel Square Garage
    street.address          intersection.directions      city state   zip
1 350 Grasmere Ave                                  Fairfield    CT 06824
2    155 Temple St Located on first floor of garage New Haven    CT 06510
  station.phone status.code expected.date          groups.with.access.code
1  203-319-9544           T    2023-10-23 TEMPORARILY UNAVAILABLE (Public)
2  203-781-8030           E                                         Public
                                              access.days.time cards.accepted
1 8am-10pm daily; for customer use only; see inside for access               
2                                      24 hours daily; pay lot               
  lev2 lev3 ev.other.info       network ev.network.web geocode.status      lat
1    2    0               Non-Networked                           GPS 41.15792
2    2    0               Non-Networked                         200-9 41.30579
        lon date.last.confirmed    id              updated.at owner.type.code
1 -73.24031          2023-04-06 36923 2023-04-06 17:17:01 UTC               P
2 -72.92740          2023-05-03 36924 2023-05-03 20:36:28 UTC               P
  federal.agency.id federal.agency.name  open.date ev.connector.types country
1                NA                     2011-06-01              J1772      US
2                NA                     2010-12-15        J1772 TESLA      US
  access.code access.detail.code federal.agency.code  facility.type ev.pricing
1      public                                               GROCERY       Free
2      public                                        PARKING_GARAGE       Free
  ev.on.site.renewable.source restricted.access rd.blends
1                                          true      <NA>
2                                         false      <NA>
  rd.blended.with.biodiesel rd.maximum.biodiesel.level nps.unit.name
1                      <NA>                         NA              
2                      <NA>                         NA              
  maximum.vehicle.class src       status lev23      network2      network3
1                    LD csv temp.unavail     2 Non-Networked Non-Networked
2                       csv        avail     2 Non-Networked Non-Networked
                                                                                                                                  label
1                             Non-Networked<br>Whole Foods Market<br>350 Grasmere Ave<br>Fairfield, CT 06824<p>Level 2: 2<br>Level 3: 0
2 Non-Networked<br>Propark America - Omni Hotel Chapel Square Garage<br>155 Temple St<br>New Haven, CT 06510<p>Level 2: 2<br>Level 3: 0
Code
leaflet(data   = dg, 
        height = 480,
        width  = 800
        ) %>% 
  addTiles() %>% ## adds the background map
  addCircleMarkers(lng    = ~lon,    ## add points 
                   lat    = ~lat,
                   radius = 5,
                   color  = 'black',
                   stroke = FALSE,   ## remove the border of the points
                   label  = ~lapply(label, HTML), ## show a label when you hover
                   popup  = ~label, 
                   fillOpacity = 0.5) %>% ## show a label when you click
  setView(lng  = -72.79458, 
          lat  = 41.51979, 
          zoom = 9) 

This is an interactive map with leaflet. There are labels that show the EV network, station name, street address, city, state, zip, and the number Level 2 and Level 3 charging stations. The dots are sized by the number of chargers at that location. Since our computer gets slow showing all the points, we are plotting just the locations in CT.