Hello, I made an interactive choropleth map with Leaflet. I created a map of countries in the EU, and displayed some data over it. However, when I run the code, what I see first is the map of the United States, and then I have to drag the map of Europe from the right hand side of the canvas, which I do not want. I have tried
leaflet(europe,options = leafletOptions(drag = FALSE)) but I do not see any difference. My code is shown below
library(maptools) library(mapdata) library(rgeos) library(sf) library(rgdal) library(leaflet) library(geojsonio) library(raster) library(rtweet) library(jsonlite) ## Add some color bins <- c(0,400000,1000000,2500000,5000000,10000000,50000000,80000000,Inf) pal <- colorBin("Dark2",domain = europe$pop_est ,bins = bins) title <- "<h3> The Population and Income of European Countries </h3>" source <- "<h5> Source: European Geo Data </h5>" labels <- paste( "<strong>Country</strong>:",trendsdf$country, "<br/>", "Trending:",trendsdf$trend1, "<br/>", "Trending:",trendsdf$trend2, "<br/>", "Trending:",trendsdf$trend3, "<br/>", "Trending:",trendsdf$trend4, "<br/>", "Trending:",trendsdf$trend5, "<br/>" ) %>% lapply(htmltools::HTML) euMap <- leaflet(europe, options = leafletOptions( drag = FALSE )) %>% setView(-96,37.8,4) %>% addTiles() %>% addPolygons( fillColor = ~pal(europe$pop_est), weight = 2, opacity = 1, color = "white", dashArray = "3", fillOpacity = 0.7, highlight = highlightOptions( weight = 5, color = "#666", dashArray = "3", fillOpacity = 0.7, bringToFront = TRUE ), label = labels, labelOptions = labelOptions( style = list("font-weight" = "normal",padding = "3px 8px"), textsize = "15px", direction = "auto" ) ) %>% addLegend(pal = pal,values = ~europe$pop_est,opacity = 0.7, title = "Population",position = "bottomright") %>% addControl(html = title,position = "topright") %>% addControl(html = source,position = "bottomleft") euMap
I wish to run the code, and only the map of Europe is displayed. I don't want to have to always drag the map of Europe out whenever I run the code. I can share my geojson and data file with you if you wish to run the code on your machine, unless you can pinpoint the problem without needing to run my code. Thanks in anticipation of your help!