Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esri-leaflet-legend

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esri-leaflet-legend

Layer legend plugin for esri-leaflet

  • 0.0.1-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

Esri Leaflet Legend

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

Example

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;
    }
});

Approach with symbols

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 '` seem to work. Suggestions are appreciated.

Development Instructions

Make sure you have the Grunt CLI installed.

  1. Fork and clone Esri Leaflet Renderers
  2. cd into the esri-leaflet-legend folder
  3. Install the dependencies with npm install
  4. run grunt from the command line. This will create minified source, run linting, and start watching the source files for changes.
  5. Make your changes and create a pull request

Dependencies

  • Leaflet version 0.7 or higher is required but the latest version is recommended.
  • Esri Leaflet

Licensing

MIT

Keywords

FAQs

Package last updated on 02 Jul 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc