Coder Social home page Coder Social logo

codeorganic / leaflet.zoomcss Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dagjomar/leaflet.zoomcss

0.0 2.0 0.0 94 KB

Add zoom level css class to map element for easy style updates based on zoom levels

License: MIT License

JavaScript 100.00%

leaflet.zoomcss's Introduction

Leaflet.ZoomCSS

Add zoom level css class to map element for easy style updates based on zoom levels

Install

Just include the leaflet.zoomcss.js file into your project.

done.

How it works

The plugin listens for zoomend events on the map, and updates a class on the map div element.

Example

When map zooms to zoomlevel 14, the div would have a class named z14 added to it

<div id="map" class="leaflet-container z14"> ... </div>

So in your css styles you could do something like:

.z14 .my-css-styled-labels{
    font-size: 12px;
    border: 1px solid grey;
}
.z15 .my-css-styled-labels{
    font-size: 10px;
    border: 1px solid grey;
}
.z16 .my-css-styled-labels{
    font-size: 8px;
    border: 0px;
}
.z13 .my-css-styled-labels, .z12 .my-css-styled-labels, .z11 .my-css-styled-labels, .z10 .my-css-styled-labels{
    display: none;
}

Another idea is to apply css-transitions for opacity animation on different zoom levels

Compatibility

Tested on Leaflet 0.7.3

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.