All Projects β†’ stefanocudini β†’ Leaflet Panel Layers

stefanocudini / Leaflet Panel Layers

Licence: mit
Leaflet Control Layers extended with support groups and icons

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Leaflet Panel Layers

Heatmap.js
πŸ”₯ JavaScript Library for HTML5 canvas based heatmaps
Stars: ✭ 5,685 (+2607.14%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet Geoman
πŸ‚πŸ—ΊοΈ The most powerful leaflet plugin for drawing and editing geometry layers
Stars: ✭ 1,088 (+418.1%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.flowecharts
leaflet plugin for Baidu Echarts
Stars: ✭ 17 (-91.9%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet Ant Path
🌿🐜 Creates a leaflet polyline with a 'ant-path' animated flux
Stars: ✭ 296 (+40.95%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet Gps
Simple leaflet control plugin for tracking gps position
Stars: ✭ 90 (-57.14%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.markercluster
Marker Clustering plugin for Leaflet
Stars: ✭ 3,305 (+1473.81%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.extras2
Extra functionality for leaflet R package.
Stars: ✭ 37 (-82.38%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.MarkerCluster.LayerSupport
Sub-plugin for Leaflet.markercluster plugin; brings compatibility with Layers Control and other plugins
Stars: ✭ 53 (-74.76%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.layergroup.collision
Leaflet plugin for uncluttering L.Markers using basic collision detection.
Stars: ✭ 82 (-60.95%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.featuregroup.subgroup
Creates a Feature Group that adds its child layers into a parent group when added to a map (e.g. through L.Control.Layers)
Stars: ✭ 79 (-62.38%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.pixioverlay
Bring Pixi.js power to Leaflet maps
Stars: ✭ 264 (+25.71%)
Mutual labels:  leaflet-plugins, leaflet
Ngx Leaflet Starter
A soup of Angular and Leaflet
Stars: ✭ 208 (-0.95%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet-active-area
A Leaflet plugin to center the map not in the center of the map but inside a DIV. Useful for responsive design.
Stars: ✭ 99 (-52.86%)
Mutual labels:  leaflet, leaflet-plugins
Iclient Javascript
Modern GIS Web Client for JavaScript, based on Leaflet\OpenLayers\MapboxGL-JS\Classic(iClient8C), enhanced with ECharts\D3\MapV etc. Contributed by SuperMap & community.
Stars: ✭ 593 (+182.38%)
Mutual labels:  leaflet-plugins, leaflet
leaflet.tilelayer.gloperations
Custom Leaflet TileLayer using WebGL to do operations on and colorize floating-point pixels
Stars: ✭ 15 (-92.86%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.markercluster.freezable
Adds ability to freeze clusters at specified zoom
Stars: ✭ 21 (-90%)
Mutual labels:  leaflet-plugins, leaflet
leaflet-area-select
Control to just select an area and provide bbox for it
Stars: ✭ 27 (-87.14%)
Mutual labels:  leaflet, leaflet-plugins
harp-leaflet
Leaflet plugin for harp.gl
Stars: ✭ 16 (-92.38%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.path.drag
Drag functionality for Leaflet vector layers
Stars: ✭ 72 (-65.71%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.browser.print
A leaflet plugin which allows users to print the map directly from the browser
Stars: ✭ 94 (-55.24%)
Mutual labels:  leaflet-plugins, leaflet

Leaflet Panel Layers

npm version

Leaflet Control Layers extended with support groups and icons

Copyright Stefano Cudini

Tested in Leaflet 0.7.x, 1.4.x

Demo:

labs.easyblog.it/maps/leaflet-panel-layers

Source code:

Github

Use Cases:

Image

Options

Option Default Description
compact false panel height minor of map height
collapsed false panel collapsed at startup
autoZIndex true set zindex layer by order definition
collapsibleGroups false groups of layers is collapsible by button
buildItem null function that return row item html node(or html string)
title '' title of panel
className '' additional class name for panel
position 'topright' position of control

Events

Event Data Description
'panel:selected' {layerDef} fired after moved and show markerLocation
'panel:unselected' {} fired after control was expanded

Methods

Method Arguments Description
addBaseLayer() layerDef,group,collapsed add new layer item definition to panel as baselayers
addOverlay() 'Text message' add new layer item definition to panel as overlay
removeLayer() 'Text searched' remove layer item from panel
configToControlLayers() 'Text searched' convert config from Control.PanelLayers to Control.Layers

Usage

Panel Item Definition formats

	{
		name: "Bar",
		icon: iconByName('bar'),
		layer: L.geoJson(Bar, {pointToLayer: featureToMarker })
	}

definition in JSON format permit to store simply the configuration type contains a Leaflet method in this case L.geoJson() args is the arguments passed to the method: L.geoJson(river)

	{
		layer: {
			type: "geoJson",
			args: [ river ]
		},
	}

definition of a group

	{
		group: "Title Group",
		collapsed: true,
		layers: [
		...other items...
		]
	}

Multiple active layers with icons

var baseLayers = [
	{
		active: true,
		name: "OpenStreetMap",
		layer: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')
	}
];
var overLayers = [
	{
		name: "Drinking Water",
		icon: '<i class="icon icon-water"></i>',
		layer: L.geoJson(WaterGeoJSON)
	},
	{
		active: true,
		name: "Parking",
		icon: '<i class="icon icon-parking"></i>',
		layer: L.geoJson(ParkingGeoJSON)
	}
];
map.addControl( new L.Control.PanelLayers(baseLayers, overLayers) );

Build panel layers from pure JSON Config

var panelJsonConfig = {
    "baselayers": [
        {
            "active": true,
            "name": "Open Cycle Map",
            "layer": {
                "type": "tileLayer",
                "args": [
                    "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png"
                ]
            }
        },
        {
            "name": "Landscape",
            "layer": {
                "type": "tileLayer",
                "args": [
                    "http://{s}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png"
                ]
            }
        },        
        {
            "name": "Transports",
            "layer": {
                "type": "tileLayer",
                "args": [
                    "http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png"
                ]
            }
        }
    ],
    "overlayers": [
        {
            "name": "Terrain",
            "layer": {
            "type": "tileLayer",
            "args": [
                "http://toolserver.org/~cmarqu/hill/{z}/{x}/{y}.png", {
                "opacity": 0.5
                }
            ]
            }
        }
    ]
};
L.control.panelLayers(panelJsonConfig.baseLayers, panelJsonConfig.overLayers).addTo(map);

Grouping of layers

L.control.panelLayers(
	[
		{
			name: "Open Street Map",
			layer: osmLayer
		},
		{
			group: "Walking layers",
			layers: [
				{
					name: "Open Cycle Map",
					layer: L.tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png')
				},
				{
					name: "Hiking",
					layer: L.tileLayer("http://toolserver.org/tiles/hikebike/{z}/{x}/{y}.png")
				}
			]
		},
		{
			group: "Road layers",
			layers: [
				{
					name: "Transports",
					layer: L.tileLayer("http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png")
				}
			]
		}
	],
	{collapsibleGroups: true}
).addTo(map);

Collapse some layers' groups

L.control.panelLayers([
	{
		name: "Open Street Map",
		layer: osmLayer
	},
	{
		group: "Walking layers",
		layers: [
			{
				name: "Open Cycle Map",
				layer: L.tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png')
			},
			{
				name: "Hiking",
				layer: L.tileLayer("http://toolserver.org/tiles/hikebike/{z}/{x}/{y}.png")
			}			
		]
	},
	{
		group: "Road layers",
		collapsed: true,
		layers: [
			{
				name: "Transports",
				layer: L.tileLayer("http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png")
			}
		]
	}
]).addTo(map);

Add layers dynamically at runtime

var panel = L.control.panelLayers();

$.getJSON('some/url/path.geojson', function(data){
	panel.addOverlay({
		name: "Drinking Water",
		icon: '<i class="icon icon-water"></i>',
		layer: L.geoJson(data)
	});
});

Build

This plugin support Grunt for building process. Therefore the deployment require NPM installed in your system. After you've made sure to have npm working, run this in command line:

npm install
grunt
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].