Reputation: 330
I was wondering whether it would possible to easily group mainland France with its overseas territories on a leaflet map, similarly to what we often see for the USA. Something like the map below.
Ideally, I could still use regular coordinates to place points on the map, but that may not be possible. I've spent a few hours to try and figure it out, but lamentably failed...
I guess one solution would be to modify the original shapefile to move the polygons of interest and expand them proportionally, but that would not be very straightforward (note that that kind of shapefile may already exist, but if it does, I haven't used the right keywords)
Any idea? Thanks for your help :)
Upvotes: 1
Views: 737
Reputation: 607
Using the first link provided by @Will Hore Lacy Multiple leaflets in a grid, you can use htmltools
to create the desired view.
library(htmltool)
library(leaflet)
First, create all maps, providing different heights for each map.
# main map
# indicate height (should be related to the number of other maps : 800px = 4 maps * 200px)
metropole <- leaflet(height = "800px") %>%
addTiles() %>%
setView(lng = 2.966, lat = 46.86, zoom = 6) %>%
addControl("Métropole", position = "bottomleft")
# smaller maps :
# height is identical (200px)
reunion <- leaflet(height = "200px") %>%
addTiles() %>%
setView(lng = 55.53251, lat = -21.133165, zoom = 8) %>%
addControl("La Réunion", position = "bottomleft")
martinique <- leaflet(height = "200px") %>%
addTiles() %>%
setView(lng = -61.01893, lat = 14.654532, zoom = 8) %>%
addControl("Martinique", position = "bottomleft")
guadeloupe <- leaflet(height = "200px") %>%
addTiles() %>%
setView(lng = -61.53982, lat = 16.197587, zoom = 8) %>%
addControl("Guadeloupe", position = "bottomleft")
guyane <- leaflet(height = "200px") %>%
addTiles() %>%
setView(lng = -53.23917, lat = 3.922325, zoom = 6) %>%
addControl("Guyane", position = "bottomleft")
Create the HTML grid.
leaflet_grid <-
tagList(tags$table(width = "100%", border = "1px",
tags$tr(
tags$td(reunion, width = "30%"), # reduce first column width
tags$td(metropole, rowspan = 4) # span across the four other maps
),
tags$tr(
tags$td(martinique)
),
tags$tr(
tags$td(guadeloupe)
),
tags$tr(
tags$td(guyane)
)
)
)
browsable(leaflet_grid)
This should give something like this :
Upvotes: 3