GithubHelp home page GithubHelp logo

zverev / leaflet-active-area Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mappy/leaflet-active-area

0.0 1.0 0.0 106 KB

A Leaflet plugin to center the map not in the center of the map but inside a DIV. Useful for responsive design.

Home Page: http://techblog.mappy.com/Leaflet-active-area/examples/index.html

HTML 29.92% CSS 4.69% JavaScript 65.39%

leaflet-active-area's Introduction

Leaflet-active-area

That Leaflet plugin allows you to use a DIV as the active area. All positionning methods (setView, fitBounds, setZoom) will be applyed on this DIV instead of the all map. A typical use case is to set a map as background (like that example) and center it on the top of the screen for example. Defining media queries on that DIV make it easy to adapt the active area according client resolution.

Demo

Try the example page !

Usage

Include the javascript file :

<script src="L.activearea.js"></script>

Add a CSS class (".activeArea" in that example) with absolute position

.activeArea { position: absolute; top: 50px; left: 50px; right: 50px; height: 200px; }

And instanciate your map like that :

var map = new L.Map(document.createElement('div')).setActiveArea('activeArea');

You can also give an object with HTML style properties:

var map = new L.Map(document.createElement('div')).setActiveArea({
    position: 'absolute',
    top: '50px',
    left: '50px',
    right: '50px',
    height: '200px'
});

Then, the map will center itself in the center of that DIV when calling setView, setZoom, fitBounds, etc.

Contribute

To run tests, you’ll need to install npm and bower libraries :

npm install && bower install

then :

(cd spec && ../node_modules/karma/bin/karma start)

Contributors

License

This code is provided under the Apache 2.0 license.

leaflet-active-area's People

Contributors

dagjomar avatar ebrelsford avatar ivansanchez avatar mcellier avatar miroslavpetrik avatar

Watchers

 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.