Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r leatflet addPolygons fill country #862

Open
antoine4ucsd opened this issue May 25, 2023 · 0 comments
Open

r leatflet addPolygons fill country #862

antoine4ucsd opened this issue May 25, 2023 · 0 comments

Comments

@antoine4ucsd
Copy link

Hello
I am trying to show a worldmap of data. filling country by my variable. when I plot it, I have an issue with country being cut on one side. is it possible to make sure it does not happen. I tried different zoom and centering but it does not seem to work...

I used these base options

leaf_map_tiles =leaflet::leaflet(world_map,
                           options = leaflet::leafletOptions(attributionControl=F,
                                                             initialTileLayerAttribution="",
                                                             attributionPrefix=" ",
                                                                minZoom = 1.3,center = c(28,13), 
                                                             maxZoom = 4,
                                                             zoom=1.3))

but when I add polygon

leaf_map1 = leaf_map_tiles%>%
        leaflet::addPolygons(stroke = T, 
                             smoothFactor = 0.3,
                             weight = 1,
                            fillOpacity = ~factop(num_site2),
                             fillColor = ~pal2(num_site2),
                             color = "white")

then it shows up like below:

example1

how can I prevent the filled country to be cut and appear on both sides?

also if want to add a tile like this one on top of it:

example2

I do

leaf_map1 = leaf_map_tiles%>%
        leaflet::addPolygons(stroke = T, 
                             smoothFactor = 0.3,
                             weight = 1,
                            fillOpacity = ~factop(num_site2),
                             fillColor = ~pal2(num_site2),
                             color = "white")%>%leaflet::addTiles(tilesURL2)

but the filled countries are always on top even with the tiles (see north of pakistan)
example3

any suggestions?

thank you for your help with both issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant