Closed SiddHyper closed 9 months ago
the hack I have to do is directly use lnglatArray but that also have a bug it seems it works for more than one elements if there is one elements it thorws error
if (elements.length === 1) {
//@ts-ignore
map.fitBounds([...elements, ...elements], {
padding: 80,
duration: 2000,
maxZoom: 17,
});
} else {
//@ts-ignore
map.fitBounds(elements, {
padding: 80,
duration: 2000,
maxZoom: 17,
});
}
If you're calling map.fitBounds
that shouldn't have anything to do with the code in this library since you're talking directly to the map instance (which is fine, but I can't do anything to alter that experience).
Are you sure that the elements
you're passing in are actually a valid argument for fitBounds
?
Likewise, in the case of elements.length == 1
I would expect an error because a single point is not a valid bounds.
(See https://maplibre.org/maplibre-gl-js/docs/API/classes/maplibregl.Map/#fitbounds and https://maplibre.org/maplibre-gl-js/docs/API/types/maplibregl.LngLatBoundsLike/)
@dimfeld I have used the same code with the library it worked perfectly fine and bounds do support only one lnglat if you use new LngLatBounds Class
And I m not sure why const bounds = new LngLatBounds(); this doesn't work
@dimfeld This seems to work the issue was I had installed the older version of maplibre 3.3.1 and I noticed you were using 3.5.0 when I change to this it works fine so closing this Thanks for your reply 😄
Hi I am using the below native Maplibre code to extend the bounds
and I have a AutoBounds.svelte like below
Map is coming from let:map fo Maplibre Component and elements are array of lng
I get and error like below