Git Product home page Git Product logo

mapbox-extensions's Introduction

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! ⭐

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

mapbox-extensions's People

Contributors

cocaine-coder avatar happyhym avatar zlx20180816 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.