npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaflet-control-basemapbar

v1.1.2

Published

Leaflet control for an attractive basemap bar

Downloads

1

Readme

Leaflet-Control-BasemapBar

A Leaflet control for adding an attractive basemap bar. Supports Bing, Google, and of course TileLayer.

https://github.com/GreenInfo-Network/Leaflet-Control-BasemapBar

http://greeninfo-network.github.io/Leaflet-Control-BasemapBar/

Requirements for Bing and Google

The Bing and Google support was written for two specific Leaflet plugins, so if you want to use them with this BasemapBar control you should use those same ones.

https://github.com/greeninfo/Leaflet-Control-BasemapBar/blob/master/leaflet-tilelayer-bing.js

https://github.com/greeninfo/Leaflet-Control-BasemapBar/blob/master/leaflet-google.js

Example of Usage

See index.html and index.js for a working example.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.16"></script>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript" src="leaflet-tilelayer-bing.js"></script>
<script type="text/javascript" src="leaflet-google.js"></script>

<link rel="stylesheet" type="text/css" href="dist/leaflet-control-basemapbar.css" />
<script type="text/javascript" src="dist/leaflet-control-basemapbar.js"></script>

var basemap_listing = [
    {
        type: 'google',
        label:'G Sat',
        url:'hybrid',
        tooltip: 'Google Photo/Satellite Imagery'
    },
    {
        type: 'bing',
        label:'b road',
        url:'street',
        apikey:"XXXYYYZZZAAABBBCCC",
        tooltip: 'Bing Streets Map'
    },
    {
        type:'xyz',
        label:'esri topo',
        tooltip: 'ESRI Topographic Basemap'
        url:'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}.jpg',
        tileLayerOptions: {
            attribution:'&copy; <a target="_blank" href="http://esri.com/" target="_blank">ESRI</a>'
        }
    },
    {
        type:'xyz',
        label:'osm',
        tooltip: 'Open Street Map',
        url:'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
        tileLayerOptions: {
            attribution:'&copy; <a target="_blank" href="http://openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>'
        }
    }
];

new L.Control.BasemapBar({ layers:basemap_listing }).addTo(map);

Constructor Options

  • layers -- A list of layer descriptions, comprising the basemap choices available. See Layer Types below for details on supported layer types.
  • position -- The usual L.Control positioning for the control; defaults to 'topright'

Layer Types

The layers parameter is a list of object literals, each one describing a basemap option.

All basemap options must have a type attribute and a label attribute. Depending on the type, additional options are required.

The label attribute must be unique as it is both the visible label for the basemap option, and also the unique identifier for the layer instance.

  • An ordinary L.TileLayer

    • type:'xyz'
    • label -- The unique name, and also and visible label, of this basemap option.
    • tooltip -- A tooltip displayed when the mouse hovers over the button for this layer. Optional, default to "".
    • url -- The URL template for this L.TileLayer. Passed to L.TileLayer as-is.
    • tileLayerOptions -- An object of other options to be passed to the L.TileLayer as-given, e.g. subdomains and attributions.
  • A Bing basemap option

    • type:'bing'
    • label -- The unique name, and also and visible label, of this basemap option.
    • url -- Which Bing basemap offering? Valid values are: street aerial aerialwithlabels
  • A Google basemap option

    • type:'google'
    • label -- The unique name, and also and visible label, of this basemap option.
    • url -- Which Google basemap offering? Valid values are: streets satellite hybrid terrain