Hi,
I have been having a problem for two days that the markerClusterOptions() is not working. I can't figure out why . When I run the code without the markerClusterOptions(), it shows the markers, but without a base map. In both cases, the base map is not shown. Any idea what is going on will be much appreciated.
Thank you
#Education Mapping
#Library ----
library(dplyr)
library(leaflet)
#Load -----
Clergy_edu <- readr::read_csv("ClergyEdu_Geo.csv")
#Clean Coordinates ----
Clergy_edu <- Clergy_edu[!is.na(Clergy_edu$lat), ]
Clergy_edu <- Clergy_edu[!duplicated(Clergy_edu$lat), ]
Clergy_edu <- Clergy_edu[!is.na(Clergy_edu$postal_code), ]
Clergy_edu <- Clergy_edu[!is.na(Clergy_edu$geo_diocese), ]
Clergy_edu <- Clergy_edu[!is.na(Clergy_edu$state), ]
non_continental <- c("AB","AK","HI","PR")
Clergy_edu <- Clergy_edu[!(Clergy_edu$state %in% non_continental), ]
data <- Clergy_edu %>%
select(
lon,
lat,
client_nbr,
first_name,
last_name,
marital_status,
geo_diocese,
geo_province,
state,
postal_code,
Address_Geo,
email_address)
#Transform to Spatial Point DataFrame ----
coords <- Clergy_edu %>%
select(
lon,
lat)
crs <- CRS("+init=epsg:4326")
spdf <- SpatialPointsDataFrame(coords = coords,
data = data,
proj4string = crs)
tmap::qtm(spdf)
#Leaflet Mapping ----
lf_clergy <- leaflet() %>%
addMarkers(spdf,
lng = spdf$lon,
lat = spdf$lat,
markerClusterOptions())
lf_clergy