0

I am trying to generate sets of Leaflet maps from a large database with global data. However, I also would like these maps to be Pacific-centered. As it stands, I can move the projection by setting the view and setting WorldCopyJump to True, but what this means is that it loads every data point depending on where the center is (so I can never get a true Pacific-centered view that shows everything).

I am generating this with the Leaflet package in R, but I can modify the JavaScript directly if need be. A code snippet, but without data:

map <- #some giant map
pal <- colorFactor(palette = 'Set1', domain = map$Value)
general_map <- map %>%
      leaflet(options=leafletOptions(worldCopyJump = TRUE)) %>%
      addProviderTiles("Esri.WorldGrayCanvas") %>%
      addCircleMarkers(
        lng = ~Longitude, lat = ~Latitude,
        radius = 4, 
        color = ~pal(Value)) %>% 
      setView(-180, 0, zoom=2)

Is there some way to do this so that I get a "true" Pacific centered map where I see all the data on both sides of the ocean at once?

New contributor
David Inman is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • See stackoverflow.com/a/38824652/4768502 and gis.stackexchange.com/q/351716/53755 . Not exactly duplicates since this involves R. Sep 10 at 20:49
  • This does in fact work, but once you scroll in the resulting interactive webpage, there is still the problem that it will only display elements on one or the other side of the dateline, which does not work for me: The data needs to still display when scrolling! Sep 13 at 6:52
  • Resolved: worldCopyJump must be set to FALSE for this fix to work. Sep 13 at 9:39

Your Answer

David Inman is a new contributor. Be nice, and check out our Code of Conduct.

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

Browse other questions tagged or ask your own question.