2

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.

6
  • 2
    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. Multiple addMiniMap functions don't have any effect (even with different position parameters)
    – Spacedman
    Nov 8 '18 at 14:26
  • I think that would be a different question. Nov 8 '18 at 14:31
  • 1
    The question asks for two inset maps (Alaska and Hawaii). Want to close it as "too broad" then?
    – Spacedman
    Nov 8 '18 at 14:53
  • 1
    @Spacedman This works quite well, but with two issues, one being that the inset map doesn't reflect the data from the main map (though this would be a different question), but more importantly, is that indeed I would want two/multiple fixed inset maps at the same time. Perhaps addMiniMap isn't a way to go here. Thank you for help all the same!
    – Denys D.
    Nov 8 '18 at 17:53
  • Best you can do is use a shapefile/spatial object where AK and HA are not in the right place geographically. But underlying tiles will be wrong. See github.com/rstudio/leaflet/issues/172 - or resort to hand-crafted Javascript and multiple map items on an HTML page.
    – Spacedman
    Nov 8 '18 at 18:33
1

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.

Source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.