I am trying to create a leaflet
map of the USA focusing on the contiguous 48 states and then add two inset maps of Alaska and Hawaii on the side. The problem is that addMiniMap()
option creates an interactive inset mini map that just shows the location of the zoom window of the main map. Rather than this, I want to have inset maps with fixed position and zoom on Alaska and Hawaii, while the main map remains interactive.
1 Answer
You need to set centerFixed
and zoomLevelFixed
:
centerFixed
Applies a fixed position to the minimap regardless of the main map's view / position. Prevents panning the minimap, but does allow zooming (both in the minimap and the main map). If the minimap is zoomed, it will always zoom around the centerFixed point. You can pass in a LatLng-equivalent object. Defaults to false.
zoomLevelFixed
Overrides the offset to apply a fixed zoom level to the minimap regardless of the main map zoom. Set it to any valid zoom level, if unset zoomLevelOffset is used instead.
leaflet() %>% addTiles() %>% addMiniMap(centerFixed=c(63, -150),zoomLevelFixed=2)
gives me an Alaska-focused mini map but I can't see how to add another one based on Hawaii. MultipleaddMiniMap
functions don't have any effect (even with differentposition
parameters)addMiniMap
isn't a way to go here. Thank you for help all the same!