Skip to content
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

Can't reconstruct a map from it's previous bounds, pitch, and bearing #6739

Closed
DannyDelott opened this issue May 24, 2018 · 1 comment
Closed

Comments

@DannyDelott
Copy link
Contributor

mapbox-gl-js version:
0.45.0

Background
My application has two pages, an Interactive Map and a Reports page. When users switch between pages, the map should look the same as how they left it.

To do this, I track the pitch, bearing, and bounds as the user interacts with the map.

Unfortunately, I am having trouble reconstructing their map, particularly when pitch or bearing are non-zero.

Steps to Trigger Behavior

  1. Instantiate a map, call fitBounds and easeTo to set the viewport.
  2. Instantiate another map, call fitBounds and easeTo with the first map's values.

Link to Demonstration

http://jsbin.com/vipofiyaco/1/edit?html,output

Expected Behavior

Both maps should look identical.

Actual Behavior

The new map looks drastically different.

@jfirebaugh
Copy link
Contributor

For a pitched map, the result of getBounds() is only approximate, because it's not possible to represent the bounds of a pitched map with a rectangular box. (#2112).

If you want to sync the state of two maps, use:

map2.easeTo({
    center: map1.getCenter(),
    zoom: map1.getZoom(),
    bearing: map1.getBearing(),
    pitch: map1.getPitch()
});

Or: https://github.com/mapbox/mapbox-gl-sync-move

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants