rmapbox-gl-jsdeck.glmapdeck

get zoom level and center point from browser console for mapbox


I'm using Rmarkdown to make a report with mapdeck which uses javascript libraries (deckgl,mapboxgl, etc) to create maps.

Once I generate the map object I can scroll and zoom around and inspect the window. What'd I'd like to do is after I scroll and zoom, extract the current zoom and center location from the browser console/inspect window so I can hard code that as a starting point. As it is, I'm constantly guessing and checking (lots of rerendering the map) a starting location and zoom level to fine tune the starting point which seems unnecessary.

I found in the console mapboxgl.getZoom but that comes back as undefined. Is it possible to get that info from the console?


Solution

  • Use show_view_state = TRUE to get a live overlay of the view's "state"

    mapdeck(show_view_state = TRUE)
    

    enter image description here