This is what I'm doing: Clicking a marker on the map to open a side panel and center the map on the marker. The side panel takes up 3/4 of the right side of the screen.
This is what I need to happen: Center the marker according to the 1/4 of the viewport that is left after the panel opens.
I can get the pixel coordinates of the marker and do the calculations of where it needs to translate to while the panel is animating open. The problem is that flyTo()
only accepts LngLatLike
objects and I cannot convert my pixel coordinates to latitude and longitude. Leaflet.js has a function called containerPointToLatLng()
that came in handy before I switched to Mapbox GL.
Given the sofistication of Mapbox GL, despite its newness, I can only imagine this is a possibility. But how?
project
andunproject
are exactly what I was looking for. That worked, but I now realize I failed to mention that I am zooming in to a fixed zoom point during theflyTo
, this only works when I stay at the same zoom level. Any idea how to accommodate for that? – Colorific