Leaflet点击Marker触发Invalid LatLng object错误求助
Leaflet点击Marker触发Invalid LatLng错误求助
使用Leaflet时遇到问题:点击Marker时触发错误 Uncaught Error: Invalid LatLng object: (NaN, 40.83618432283402),错误中显示的是地图中心坐标(经度无异常)。
已经查阅大量同类错误案例,主流方案为修正Marker绘制坐标,但此方法无效。尝试修改Marker位置坐标并转换为LatLng类型,也无明显改善。疑惑问题或许不在Marker本身,但为何只有点击Marker时才触发错误?
调用栈截图:显示错误触发的调用链路
Marker绘制代码:
<MarkerClusterGroup key={Date.now()} iconCreateFunction={createClusterCustomIcon1} spiderfyDistanceMultiplier={3} maxClusterRadius={95} singleMarkerMode={false} animated={false} > {context.singleDay && points.map((nat, index) => ( (context.min_datetime <= Date.parse(nat.datetime) && Date.parse(nat.datetime) <= context.max_datetime) && <Marker icon={GetIcon(10, 10, nat.temperature)} key={index} position={new L.LatLng(nat.longitude,nat.latitude)} > <Popup closeButton={false} key={index}> Координаты: {nat.latitude}, {nat.longitude} <br/> Температура: {nat.temperature} <br/> Время: {nat.datetime} </Popup> </Marker> ))} {context.daysInRange && points.map((nat, index) => ( <Marker icon={GetIcon(10, 10, nat.temperature)} key={index} position={new L.LatLng(nat.longitude, nat.latitude)} updateWhenZooming={false} updateWhenIdle={true} > <Popup closeButton={false} key={index}> Координаты: {nat.latitude}, {nat.longitude} <br/> Температура: {nat.temperature} <br/> Время: {nat.datetime} </Popup> </Marker> ))} </MarkerClusterGroup>
恳请各位提供帮助!
内容的提问来源于stack exchange,提问作者mr.DenisG
相关产品推荐
相关产品推荐

