All Projects → consbio → Leaflet.basemaps

consbio / Leaflet.basemaps

Licence: isc
A tile driven basemaps control for Leaflet.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Leaflet.basemaps

Leaflet.flowecharts
leaflet plugin for Baidu Echarts
Stars: ✭ 17 (-70.69%)
Mutual labels:  leaflet
Filemap.xyz
upload files to a geographic point. never memorize a link again.
Stars: ✭ 29 (-50%)
Mutual labels:  leaflet
Papyrusjs
papyrus.js renders maps of Minecraft: Bedrock Edition worlds using node.js, LevelDB and leaflet.
Stars: ✭ 50 (-13.79%)
Mutual labels:  leaflet
Leaflet Deepzoom
Display DeepZoom tiles with Leaflet
Stars: ✭ 17 (-70.69%)
Mutual labels:  leaflet
Leaflet Ais Tracksymbol
AIS Extension for leaflet-tracksymbol It can display AIS Contacts on the Map.
Stars: ✭ 27 (-53.45%)
Mutual labels:  leaflet
Leaflet.extras2
Extra functionality for leaflet R package.
Stars: ✭ 37 (-36.21%)
Mutual labels:  leaflet
Agentmaps
Make social simulations on interactive maps with Javascript! Agent-based modeling for the web.
Stars: ✭ 822 (+1317.24%)
Mutual labels:  leaflet
Leaflet.draw.drag
Drag feature functionality for Leaflet.draw
Stars: ✭ 56 (-3.45%)
Mutual labels:  leaflet
Mapboard
A framework for data-rich web mapping 🌎📊✨
Stars: ✭ 29 (-50%)
Mutual labels:  leaflet
Ngx.leaflet.component
angular 2+ / leaflet 1.x component collection
Stars: ✭ 46 (-20.69%)
Mutual labels:  leaflet
Pm2.5 Idw Map
PM2.5 IDW Map from PM2.5 open data portal
Stars: ✭ 14 (-75.86%)
Mutual labels:  leaflet
Leaflet
🍃 JavaScript library for mobile-friendly interactive maps
Stars: ✭ 32,591 (+56091.38%)
Mutual labels:  leaflet
R Community Explorer
Data-Driven Exploration of the R Community
Stars: ✭ 43 (-25.86%)
Mutual labels:  leaflet
Atd Data And Performance
Open data and performance hub for the City of Austin Transportation Department
Stars: ✭ 17 (-70.69%)
Mutual labels:  leaflet
Inloco
A Geographic Information System (GIS) used by Ministério Público do Estado do Rio de Janeiro to show social, institutional and administrative data , based on React and Leaflet, interacting with a GeoServer back-end.
Stars: ✭ 51 (-12.07%)
Mutual labels:  leaflet
Leaflet.annotate
A Leaflet plugin integrating schema.org to markup items in your geographic web map machine readable.
Stars: ✭ 5 (-91.38%)
Mutual labels:  leaflet
Leafletpano
A simple tool which tiles large images to publish them for web and mobile
Stars: ✭ 34 (-41.38%)
Mutual labels:  leaflet
Leaflet Geoman
🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
Stars: ✭ 1,088 (+1775.86%)
Mutual labels:  leaflet
Leaflet Swoopy
⤵️ Swoopy Arrow Plugin for Leaflet
Stars: ✭ 52 (-10.34%)
Mutual labels:  leaflet
Svelte Pick A Place
Javascript location picker built with Svelte
Stars: ✭ 44 (-24.14%)
Mutual labels:  leaflet

Leaflet.Basemaps

A tile driven basemaps control for Leaflet.

It allows you to create a user interface control for choosing the basemap used on the map, based on a tile from a the underlying tile service.

See the example.

Tested with Leaflet 1.1.0

Install

npm install leaflet-basemaps

Usage

Include the CSS:

<link rel="stylesheet" href="L.Control.Basemaps.css" />

Include the JavaScript:

<script src="L.Control.Basemaps-min.js"></script>

The control expects a list of TileLayer instances, constructed in the normal way.

An optional label property can be added in the options for each basemap, and this will be used to populate the tooltip (HTML title attribute) for that basemap.

Each basemap is represented using a tile from the underlying tile service. Choose the tile x, y, z that provides the best looking representative basemap image for your application.

TileLayer.WMS layers can also be used, and tile coordinates will be converted to bounding boxes to request the preview thumbnail.

The preview shows an alternative basemap to the currently selected basemap to be more apparent as a toggle between basemaps.

Note: this automatically adds the first basemap in your list to the map during initialization, so you don't need to add that TileLayer to your map.

Example usage:

var basemaps = [
    L.tileLayer('//{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png', {
        attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
        subdomains: 'abcd',
        maxZoom: 20,
        minZoom: 0,
        label: 'Toner Lite'  // optional label used for tooltip
    }),
    L.tileLayer('//{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {
        attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
        subdomains: 'abcd',
        maxZoom: 20,
        minZoom: 0,
        label: 'Toner'
    }),
    L.tileLayer('//{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png', {
        attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
        subdomains: 'abcd',
        maxZoom: 16,
        minZoom: 1,
        label: 'Watercolor'
    }),
    L.tileLayer.wms('https://firms.modaps.eosdis.nasa.gov/wms/viirs', {
        layers: 'NASA FIRMS',
        label: 'NASA Fire Hotspots'
    })
];

map.addControl(L.control.basemaps({
    basemaps: basemaps,
    tileX: 0,  // tile X coordinate
    tileY: 0,  // tile Y coordinate
    tileZ: 1   // tile zoom level
}));

Toggle Mode

To enable toggling between 2 basemaps, simply provide only 2 basemaps.

See toggle example.

Alternative Basemap Icons

To use a different thumbnail for your basemap, simply provide iconURL.

See example.

iconURL can point to a tile image within that basemap, but at a different zoom level, x, or y position than the default for the basemaps. Or it can point to an arbitrary image. Just make sure that the target image is not too big.

Example:

L.tileLayer('//stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png', {
    attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
    subdomains: 'abcd',
    maxZoom: 20,
    minZoom: 0,
    label: 'Toner',
    iconURL: '//stamen-tiles-a.a.ssl.fastly.net/toner/4/2/5.png'
}),
L.tileLayer('//stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png', {
    attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
    subdomains: 'abcd',
    maxZoom: 16,
    minZoom: 1,
    label: 'Watercolor',
    iconURL: 'alt_icon.jpg'
})

Development

  • npm install
  • node_modules/.bin/gulp (starts file watcher)
  • node_modules/.bin/gulp build ( builds minified version)

Credits:

Developed and maintained with support from the Peninsular Florida Landscape Conservation Cooperative and additional support from the U.S. Forest Service Northwest Regional Climate Hub.

Contributors:

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].