Code Monkey home page Code Monkey logo

proj4leaflet's Introduction

Proj4Leaflet

This is an early attempt at integrating Proj4js with the excellent map client Leaflet. We decided to put this into a separate library for now to avoid adding unnecessary dependencies to Leaflet.

Example

Defines the EPSG:2400 (RT90) projection in Proj4 format and returns a Leaflet CRS object which can be used as the "crs" option to L.Map.

// RT90
L.CRS.proj4js('EPSG:2400',
  '+lon_0=15.808277777799999 +lat_0=0.0 +k=1.0 +x_0=1500000.0 ' +
  '+y_0=0.0 +proj=tmerc +ellps=bessel +units=m ' +
  '+towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +no_defs', 
  new L.Transformation(1, 0, -1, 0));

// ETRS89 / UTM zone 33N
L.CRS.proj4js('EPSG:25833', 
  '+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs', 
  new L.Transformation(1, 2500000, -1, 9045984));

// SWEREF 99 TM
L.CRS.proj4js('EPSG:3006', 
  '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
  new L.Transformation(1, -218128.7031, -1, 6126002.9379));

More details in examples/script.js

Transformations

Transformation turns projected coordinates into pixel coordinates corresponding to a given zoom.

It uses the following formula:

point.x = scale * (this._a * point.x + this._b);                            
point.y = scale * (this._c * point.y + this._d);     

which we usually define as

a = 1 
b = -(x_origin)
c = -1
d = y_origin

proj4leaflet's People

Contributors

mourner avatar

Stargazers

 avatar

Watchers

 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.