Is there a pattern to use fitBounds? #376
Closed
MauricioRobayo
started this conversation in
General
Replies: 1 comment 1 reply
-
You can also use the But since the const bounds = markers.reduce((bounds, {position}) => ({
west: Math.min(bounds.west, position.lng),
east: Math.max(bounds.east, position.lng),
north: Math.max(bounds.north, position.lat),
south: Math.min(bounds.south, position.lat)
}), {west: 180, east:-180, north:-90, south:90}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I want to render a map but I don't know ahead of time the postion of the map, it is derived from the markers I am rendering.
Something like this:
Since I don't know the bounds ahead of time but I need to render the map to be able to calculate the bounds based on the markers, this can cause a flash of content where the map is rendered based on the default center and zoom and then swaps to use the bounds.
Is this the way to do it or is there another pattern to follow to avoid rendering the map until the bounds are known?
Beta Was this translation helpful? Give feedback.
All reactions