【发布时间】:2021-10-25 07:34:12
【问题描述】:
大家早上好, 我创建了一个带有 React-leaflet 的 SPA,除了可访问性之外,它都可以正常工作。
我的地图自动添加了多个标记,但是当我尝试使用 Tab 进入地图时,我得到的只是放大/缩小按钮和地图名称,标记被完全忽略,因此我无法将 ARIA 添加到它们。
有谁知道是否可以为每个标记添加制表符? 理想情况下,我希望拥有它,这样当用户点击标记时,它会读取特定数据,但是如果这不可能,我愿意接受建议。
如果有帮助,我将如何生成/填充地图:
标记:--
const showDataOnMap = (countryList, y) => (
countryList.map(country => (
<Circle
key = {country.country}
center={[country.countryInfo.lat, country.countryInfo.long]}
fillOpacity={0.4}
pathOptions={{color:casesTypeColors[y].hex,
fillColor:casesTypeColors[y].hex}}
radius={
Math.sqrt(country[y] * 12000)
}
eventHandlers={{
click: () => {
console.log(mapRef.current)
},
}}
tabIndex="0"
aria-label="circle"
>
<Popup tabIndex="0" aria-live="polite" ref={mapRef}>
<div>
<img className="mapFlag" src={country.countryInfo.flag} alt={country.country} role="image"/>
{country.country}
</div>
<p>
{`${y}: ${numeral(country[y]).format("0,0")}`}
</p>
</Popup>
</Circle>
)
)
)
地图:--
return (
<div className="map" aria-label={`World-map-${active}`} tabIndex="0" role="application">
<MapContainer center={coords} zoom={2}>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
aria-label="Copyright-information"
aria-hidden="true"
/>
{showDataOnMap(table,checkActive())}
</MapContainer>
</div>
)
【问题讨论】:
标签: reactjs leaflet accessibility wai-aria react-leaflet