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

mapbox-extensions

v1.3.40

Published

[![npm](https://img.shields.io/npm/v/mapbox-extensions)](https://www.npmjs.com/package/mapbox-extensions) mapboxgl controls : measure、switch map、switch layers、doodle、back ... ## DEMO [examples](https://giserver.github.io/mapbox-extensions/example-dist/)

Downloads

34

Readme

mapbox-extensions 中文

npm
mapboxgl controls : measure、switch map、switch layers、doodle、back ...

DEMO

examples

usage

CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mapbox-extensions.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.css" rel="stylesheet">

NODE

npm install / yarn add  mapbox-extensions

import { SwitchLayerControl } from 'mapbox-extensions'
import 'mapbox-extensions/dist/index.css'

Give a Star! :star:

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

features

Measure

map.addControl(new MeasureControl({
    horizontal : true,         //default false   
    btnBgColor : 'red',        //default '#ffffff'
    btnActiveColor:'red',      //default '#ddd'
    geometryClick:true,        //defualt false 
    enableModes:['LineString'],//default all
    onStart:()=>{},            
    onStop:()=>{},             
    measurePointOptions:{      
    },
    measureLineStringOptions:{ 
    },
    measurePolygonOptions:{    
    }
}))

Measure mouse operation

  • left click : add a point
  • right click : remove a point
  • left double click : finish measure and start next

Back to origin

map.addControl(new BackToOriginControl({}))

BackToOrigin

Switch Map with swtch-layer

map.addControl(new SwitchMapControl({
    satelliteOption:{        
        name: "satellite",  
        textColor : 'red',   
        backgroundImage : "",
    },
    showSatelliteDefault:true, 
    extra:{  // default undefined, similar to SwitchLayerControlOptions
        nailActiveColor : "red" 
    }
}));

SwitchMap

Switch Layer

map.addControl(new SwitchLayerControl({
    name:"Layer Manager" ,       
    position:"top-left",     

    selectAndClearAll:true, 
    selectAllLabel:"select all",   
    clearAllLabel:"clear all",    

    showToTop:true,         
    topLayerId:"",          

    layerGroups:{           
        "layer group 1":{
            mutex:true,         
            collapse:true,      
            uiType:"SwitchBtn", 
            layers:[
               {
                 name:"layer1",   
                 layer: {},     
                 fixed:true,    
                 zoom:-100,   
                 easeToOptions:{},   
                 mutex:true,          
                 mutexIdentity:"t1",  
                 active:true,         
                 backgroundImage:"",  
                 backgroundImageActive:"",
 
                 onVisibleChange:(visible:boolean)=>{}
               }
            ]
        }
    }
}));

SwitchLayer

SwitchLayer-Mobile

Extend

map.addControl(new ExtendControl({
    img1 : "",              
    img2 : "",              
    content : div,          
    position : "top-left",  
    mustBe : "pc",         

    onChange:(open:boolean)=>{}
}));

Extend

Extend-Mobile

Doodle

map.addControl(new DoodleControl({

    name: '',           
    reName : '',        
    exitText : '',      
    lineColor : '',     
    lineWidth : 1,      
    polygonColor: '',   
    polygonOpacity : 1, 

    onStart: () => { measureControl.stop() },

    onDrawed: polygon => { () => { alert(JSON.stringify(polygon)) } },

    onClear:()=>{},

    onExit:()=>{}
}))

Doodle

Location

map.addControl(new LocationControl({ fractionDigits: 4 }));

Zoom

map.addControl(new ZoomControl());

Eye

map.addControl(new EyeControl(map));

Eye

Grid

map.addControl(new GridControl({ show: true }));

Grid