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

setting [center] on map affects zoom & vice versa #2

Closed
Tobbyte opened this issue Nov 14, 2017 · 3 comments
Closed

setting [center] on map affects zoom & vice versa #2

Tobbyte opened this issue Nov 14, 2017 · 3 comments
Labels

Comments

@Tobbyte
Copy link

Tobbyte commented Nov 14, 2017

Dynamically changing this.center when

<mgl-map
...
    [center]="center"
    [zoom[="zoom"
...

resets the zoom to inital value - same the other way round.
(can be seen in demo: examples/center-on-symbol.component)

Expected behaviour:
Changing center/zoom shouldn't affect the zoom/center

@Tobbyte Tobbyte changed the title setting [center] on map affects zoom setting [center] on map affects zoom & vice versa Nov 14, 2017
@Wykks Wykks added the bug label Nov 14, 2017
@Wykks
Copy link
Owner

Wykks commented Nov 14, 2017

Thinking a bit more about this, I think this is correct.
Otherwise if the user zoom the map, but afterward your app need to set the zoom to the same as before, you're kinda stuck (except changing zoom directly using the map instance but that doesn't count).
In react-mapbox-gl it's handled by passing zoom as an array, which allow the app to just change the ref to "force" a zoom change.
I think we can do better in Angular, with two way data binding. I'll try do that

@Tobbyte
Copy link
Author

Tobbyte commented Nov 15, 2017

I understand you from a technical standpoint. From a UX perspective, I'd expect the map to not zoom when I click a POI - when I have changed the zoom before.
Maybe that could be a solution: If the user has changed zoom / center, keep that on programmatic changes (f.e. click on a poi and center map there) and instead add a new UI element (like the locate me button) to reset to initial values?

@Wykks
Copy link
Owner

Wykks commented Nov 20, 2017

Okay, I tried to make it work with two way data binding, but it's a fail.
Let's fallback to the same solution of react-mapbox-gl.

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

No branches or pull requests

2 participants