I'd like to have my map display in equirectangular mode rather than the default mercator. How can I do this? Here is my code:

<link rel = "stylesheet" href = "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
<script src = "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<div id = "map" style = "width:900px; height:580px"></div>

    var map = new L.map('map', {center: [0,0], zoom: 5})
    map.addLayer(new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'))

    // what should go here to make the map equirectangular?


replace this line:
var map = new L.map('map', {center: [0,0], zoom: 5})
with this line:
var map = new L.map('map', {center: [0,0], zoom: 5, crs: L.CRS.EPSG4326})

Doing so changes the crs (coordinate reference system) from the default mercator projection to equirectangular.

More generally this is a "map option". More map options can be found in the api: https://leafletjs.com/reference-1.3.0.html#map-option

| improve this answer | |
  • Do not forget to use a Tile Server that gives you tiles in the appropriate projection. OSM tiles are only in Web Mercator. – ghybs May 20 '18 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.