-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for alt text for legend images #7
base: master
Are you sure you want to change the base?
Conversation
… 'label'. Add a map server to example that has values for the label property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I
src/Controls/Legend.js
Outdated
@@ -3,8 +3,8 @@ EsriLeaflet.LegendControl = L.Control.extend({ | |||
options: { | |||
listTemplate: '<ul>{layers}</ul>', | |||
layerTemplate: '<li><strong>{layerName}</strong><ul>{legends}</ul></li>', | |||
listRowTemplate: '<li><img width="{width}" height="{height}" src="data:{contentType};base64,{imageData}"><span>{label}</span></li>', | |||
emptyLabel: '<all values>', | |||
listRowTemplate: '<li><img alt="map legend icon representing {label}" width="{width}" height="{height}" src="data:{contentType};base64,{imageData}"><span>{label}</span></li>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like hard-coded English phrases in the template, it increases the accessibility, but affects the localisation, is there a way around it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this. Would adding an option that let's the user specify the text of the alt
attribute be a reasonable solution?
Something like the following:
L.esri.Controls.legend([dynamicLayer, featureLayer], {
position: 'topright',
altTextTemplate: 'icon representing a map layer'
}).addTo(map);
I would still want to use the label
property, but understand it could get tricky without knowing what the user would pass in?
Any thoughts or suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a good suggestion! But probably it would require a second pass to substitute? or it can be replaced where it's added.
listRowTemplate: '<li><img alt="'+ altTextTemplate +'" width="{width}" height="{height}" src="data:{contentType};base64,{imageData}"><span>{label}</span></li>',
Thanks a lot for your PR, do you think we can fix the localisation issue there? |
Replace with just the map service legend 'label' property. Update README to reflect change.
I removed the English text in the I still think it would be cool to add a constructor option to set default Thanks for the feedback. |
I suggested a way to pass the alt string template, do you want to add it? I can merge without it though, if you don't have time |
I did try something similar to what you proposed. But I kept getting I don't know when I'll be able to dig into this further, so I would be fine if you merge it as is. |
Did you want to merge it as is? Even though we want to add in the user-defined alt template text. This will at least provide a basic level of the |
I've added an
alt
property to the legend images. I'm using the label property.I also added a second map service to the example that has label values set.