Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
esri-leaflet-legend
Advanced tools
Esri leaflet plugin for retrieving map service legends. Also aimed to cover the lack of similar API for FeatureServers and render the symbols from layer definitions. No assumptions on how you want to render the legend, you are simply getting the legend data(see format). There is a templating example in the demo.
The legend task for mapservers is ready & tested, feature layers part is developed separately and will be released later
var map = L.map('map', {maxZoom: 20}).setView([ 41.78408507289525, -88.13716292381285], 18);
L.esri.basemapLayer('Gray').addTo(map);
var waterNetwork = L.esri.dynamicMapLayer(
'https://sampleserver6.arcgisonline.com/arcgis/rest/services/Water_Network/MapServer', {
useCors: false
}).addTo(map);
waterNetwork.legend(function(error, legend){
if(!error) {
var html = '<ul>';
for(var i = 0, len = legend.layers.length; i < len; i++) {
html += '<li><strong>' + legend.layers[i].layerName + '</strong><ul>';
for(var j = 0, jj = legend.layers[i].legend.length; j < jj; j++){
html += L.Util.template('<li><img width="{width}" height="{height}" src="data:{contentType};base64,{imageData}"><span>{label}</span></li>', legend.layers[i].legend[j]);
}
html += '</ul></li>';
}
html+='</ul>';
document.getElementById('legend').innerHTML = html;
}
});
L.esri.Controls.Legend
will render symbology for a single or multiple layers,
loading the data and rendering it in a queue. That can take some time, but it's
a lot of requests(one per each feature layer).
var map = L.map('map').setView([...], 12);
L.esri.Controls.legend([dynamicLayer, featureLayer], {position: 'topright'}).addTo(map);
You can also adjust the templates for legend output:
{
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>'
}
var f = new L.esri.Layers.FeatureLayer('/some/arcgis/rest/services/xxx/FeatureServer/0', {}).addTo(map);
f.legend(function(error, legend) { /* same format as /legend API */ });
// or
var m = L.esri.Services.MapService('some/MapServer/', {});
m.legend(function(error, legend) { /* same format as /legend API */ });
For featureservers(and ArcGIS servers <= 10.0 with no legend
API) I want to mimic
the API with the data taken from layer definitions. So the symbols have to be rendered
into <canvas>
and exported as base64. But esriPMS
and esriPFS
symbols are
problematic: I can't get CORS patterns to work, no solution with avoiding cacheing
or <img crossOrigin=''>
seem to work. Suggestions are appreciated.
esriST
is not implemented yet - cannot find a working example.
Make sure you have the Grunt CLI installed.
cd
into the esri-leaflet-legend
foldernpm install
grunt
from the command line. This will create minified source, run linting, and start watching the source files for changes.MIT
FAQs
Layer legend plugin for esri-leaflet
We found that esri-leaflet-legend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.