在过去的几个小时里,我一直用头撞桌子。
我试图让 Mapbox 放大所有标记的边界区域的负载。
但是,这是我在下面的代码中遇到的错误。
此错误出现在下面的控制台日志图像之后,因此 lat lng 坐标肯定存在。
未捕获的错误:无效的 LngLat 对象:(NaN,NaN)
const onLoad = () => {
let points = [];
props.cats.forEach(cat => (
points.push([ cat.lat, cat.lng ])
));
points.length > 0 && ref.current.getMap().fitBounds(points, {
padding: { top: 50, bottom: 50, left: 50, right: 50 },
easing(t) {
return t * (2 - t);
},
});
};
就我而言,当填充值很高时,我遇到了相同的错误。
//this did not work
map.fitBounds(fitBounds, {padding: 150});
//this worked
map.fitBounds(fitBounds);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)