-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract & Restrict Bounds/Zoom #211
Comments
Going through the JS code I seem to be able to do this in the browser console for zoom |
Currently am accessing zoom using the following: JavaScript:
added to ui.R
getting zoom via event
Problem with this is that an event is required to trigger |
I think we need to make use of
References: |
Seems to be working great so far - just need to find a way to calculate the bounds based from the lat/lon. Thanks. |
yeah I reckon there's probably a way to either calculate that or get it directly from somewhere, but I haven't found the solution yet. |
maybe useful related to settings bounds: visgl/react-map-gl#442 Also I'm digging around for how the mapbox tiles are queried - it seems as if that requires the bounding box to determine the tiles - hopefully will find something there. |
I was able to get kinda close using the following, its not perfect due to assuming spherical earth, but conceptually it seems fine. Works good enough for my current needs
|
asking the source: visgl/deck.gl#3344 |
@zacdav I won't be able to update this for a few days so you're welcome to have a go and submit a PR if you get a good solution working. |
@zacdav with your updates, have you noticed any performance issues? I'm wondering if constantly creating a new |
I was wondering the same thing the other day - but I was zooming in and out quite quickly testing it and it seemed fine for me. I will test more at work later with the dashboard I needed this for. |
Don't seem to notice any performance degradation. Is working great. |
now in master |
Reopening: East & West aren't constrained to |
I've added more events, and an https://github.com/SymbolixAU/mapdeck/blob/master/inst/htmlwidgets/mapdeck.js#L83 |
related: #237 |
In the absence of a fix in Deckgl for #211 (comment), I've added these conditions const viewport = new WebMercatorViewport(viewState);
const nw = viewport.unproject([0, 0]);
const se = viewport.unproject([viewport.width, viewport.height]);
const w = nw[0] < -180 ? -180 : ( nw[0] > 180 ? 180 : nw[0] );
const n = nw[1] < -90 ? -90 : ( nw[1] > 90 ? 90 : nw[1] );
const e = se[0] < -180 ? -180 : ( se[0] > 180 ? 180 : se[0] );
const s = se[1] < -90 ? -90 : ( se[1] > 90 ? 90 : se[1] );
viewState.viewBounds = {
north: n, //nw[1],
east: e, //se[0],
south: s, //se[1],
west: w //nw[0]
}; Which I think are what's needed. |
Given the update to v8.0 of deck.gl - #239 This function will be changing, and so the output returned back to R may change slightly too. |
Let me know if you need any support on this |
gone back to the source again - visgl/deck.gl#4184 |
I think it's all fine now... |
Related to #324 |
In leaflet the ability to extract the zoom and bounds of the current map is accessible via
input$<map_id>_zoom
andinput$<map_id>_bounds
, would it be possible to expose these for mapdeck too? Additionally the ability to set the zoom and bounds would be useful.I've tried to see if there is existing functionality for this - but not entirely sure how easy it is to access.
The text was updated successfully, but these errors were encountered: