leaflet-providers icon indicating copy to clipboard operation
leaflet-providers copied to clipboard

base Maps and overlay

Open vincent3569 opened this issue 7 years ago • 5 comments

hi leaflet-providers uses some providers defined in L.TileLayer.Provider.providers{} object. but this doesn't define if the provider is a base map or an overlay. and in your preview, you add a function to filter provider that are overlay (https://github.com/leaflet-extras/leaflet-providers/blob/master/preview/preview.js).

Is there a way to specify an attribute "base map or overlay" in providers definition? It would be more consitant and may be used to easily choose/display providers as they are (base map or overlay) in control layer of leaflet (https://leafletjs.com/examples/layers-control/)

vincent3569 avatar Aug 30 '18 10:08 vincent3569

As this would be really usefull in my WP Plugin I hereby volunteer to craft a PR.

I would simply add a layerType property with possible values base or overlay.

Like this:

		[...],
		OpenSeaMap: {
			url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
			layerType: 'overlay',
			options: {
				attribution: 'Map data: &copy; <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
			}
		},
		[...],
		HikeBike: {
			url: 'https://tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png',
			layerType: 'base',
			options: {
				maxZoom: 19,
				attribution: '{attribution.OpenStreetMap}',
				variant: 'hikebike'
			},
			variants: {
				HikeBike: {},
				HillShading: {
					layerType: 'overlay',
					options: {
						maxZoom: 15,
						variant: 'hillshading'
					}
				}
			}
		},
		[...],
		Wikimedia: {
			url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png',
			layerType: 'overlay',
			options: {
				attribution: '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia</a>',
				minZoom: 1,
				maxZoom: 19
			}
		},

Any reason why this might be a bad Idea? Anything I overlooked?

mcguffin avatar Dec 21 '19 10:12 mcguffin

This info would indeed come in very handy! @mcguffin's proposal looks good to me. Since the data structure is meant to be consumed by the internal L.tileLayer.provider() extension and not by leaflet directly, I don't see how a new layerType property could do any harm.

I have one remark concerning the data type of the property: With two layerTypes ['base', 'overlay'] all you'd really need is a bool isOverlay [true/false], unless you think either leaflet or this extension is going to add another layer type at some point. What other type that could be, I don't know. I wouldn't care either way though, it's more of a philosophical question of extensibility vs. simplicity.

h0lg avatar Aug 15 '20 14:08 h0lg

Anyone here can push a PR for that ?

brunob avatar Sep 02 '22 13:09 brunob

I could squeeze it in at some point, but will let @mcguffin take point - since he already volunteered.

h0lg avatar Sep 18 '22 10:09 h0lg

Any news about this ?

brunob avatar Feb 10 '23 09:02 brunob