Skip to content

Instantly share code, notes, and snippets.

@davidrs
Last active June 12, 2018 15:47
Show Gist options
  • Save davidrs/e3dc314c7e230f40b813 to your computer and use it in GitHub Desktop.
Save davidrs/e3dc314c7e230f40b813 to your computer and use it in GitHub Desktop.
<!--
1. Load legend json from the service
-->
<script>
var myService = 'http://fake.com/arcgis/rest/services/Timor/IlliteracyRate/MapServer';
$.ajax({
url: myService + '/legend',
data:{f: 'pjson'},
dataType: 'jsonp'
}).then(function(esriLegend){
_.template(Template)({esriLegend: esriLegend});
});
</script>
<!-- HTML for a _.template file that parses the json, and creates images for it.
<% _.each(esriLegend, function(legend) {
if (legend.label && legend.imageData) {
%>
<div>
<img src="data:<%= legend.contentType %>;base64,<%= legend.imageData %>" class="color-block" />
<%= legend.label %>
</div>
<% }
}); %>
<% } %>
@pmacMaps
Copy link

Do you have a working example of this? I'd like to try to implement it, but have never worked with whatever is going on at line 16. What kind of tag is that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment