Code Monkey home page Code Monkey logo

leaflet's Introduction

Leaflet rotate

An unofficial branch for making rotation work in leaflet master branch.

Code example

var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
	osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
	osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib});

var map = L.map('map', {rotate: true})
		.setView([55, 10], 4)
		.addLayer(osm);

or if you want touch interactions to rotate the map:

var map = L.map('map', {rotate: true, touchRotate: true})
		.setView([55, 10], 4)
		.addLayer(osm);

Live examples

Simple rotated map with a line, markers and a basemap

Map rotated according to the orientation of your device, if supported

Map with tri-state control for map rotation (locked, unlocked, follow)

Map with draggable markers

Code for these examples is hosted in the debug/rotate folder

Installation

To use this branch, you will need to build it. Follow the steps of the Leaflet guide for Building Leaflet from the Source. Then get the JavaScript file from the dist folder.

Motivation

Map rotation is the most request features on leaflet's feature suggestion website, see Map rotation and a Github issue which started in 2011 rotation of map and contents to x degress.

For good reasons, it has never been implemented into Leaflet's core code.

@IvanSanchez started a "rotate" branch a few years ago to try and add this feature. Then @hyperknot created a "rotate-rc1" branch to make @IvanSanchez work with the latest leaflet changes (RC1 at the time). The project is now maintained by @fnicollet, in the "rotate-master" branch. This branch is regularly merged with master, so you can expect the same issues that you have with Leaflet's master branch (+ maybe more).

Note: Here is a squash from all commits of the original "rotate" branch made by @IvanSanchez: https://github.com/hyperknot/Leaflet/commit/0448ffd8f28730ff3c59822351d4a04f54a3972f

Bug Reports & Feature Requests

If you encounter issues related to Leaflet itself, please log an issue on the Leaflet project directly: https://github.com/Leaflet/Leaflet/issues/new

If you encounter issues related to map rotation specifically, please log an issue on the this branch: https://github.com/fnicollet/Leaflet/issues

Licence

Same as Leaflet's licence

leaflet's People

Contributors

andriiheonia avatar aparshin avatar bennlich avatar brunob avatar danzel avatar dravnic avatar edjafarov avatar fastrde avatar fnicollet avatar ghybs avatar guiswa avatar hyperknot avatar iirvine avatar ivansanchez avatar jacobtoye avatar jasonsanford avatar jfirebaugh avatar jieter avatar leplatrem avatar mattiasb avatar mortenbekditlevsen avatar mourner avatar nathancahill avatar patrickarlt avatar perliedman avatar rowanhogan avatar snkashis avatar stefanocudini avatar tmcw avatar yohanboniface avatar

Watchers

 avatar  avatar  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.