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

Advice to hardlink two maps #5221

Open
artyomb opened this issue Dec 16, 2024 · 2 comments
Open

Advice to hardlink two maps #5221

artyomb opened this issue Dec 16, 2024 · 2 comments
Labels
need more info Further information is requested

Comments

@artyomb
Copy link

artyomb commented Dec 16, 2024

Please help me to hard sync two maps (center, zoom, bearing, pitch) to unsure there won't be desynced frames.
Ideally within single animation frame.

Current syncMaps method causes delayed and desynchronized map positions during interactions.

const map1 = new maplibregl.Map({
  container: 'map1',
  style: 'first-style-url'
});

const map2 = new maplibregl.Map({
  container: 'map2',
  style: 'second-style-url'
});

function syncMaps(mapA, mapB) {
  mapA.on('move', () => {
    const center = mapA.getCenter();
    const zoom = mapA.getZoom();
    const bearing = mapA.getBearing();
    const pitch = mapA.getPitch();
    mapB.jumpTo({center, zoom, bearing, pitch});
  });
}

syncMaps(map, map_base);
@HarelM
Copy link
Collaborator

HarelM commented Dec 16, 2024

You might want to listen to the render event?

@HarelM HarelM added the need more info Further information is requested label Dec 16, 2024
@artyomb
Copy link
Author

artyomb commented Dec 17, 2024

Could someone please provide a working code snippet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants