leaflet-providers
leaflet-providers copied to clipboard
base Maps and overlay
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/)
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: © <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?
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.
Anyone here can push a PR for that ?
I could squeeze it in at some point, but will let @mcguffin take point - since he already volunteered.
Any news about this ?