I'm trying to use leaflet to add an equi-rectanglular map layer on a scatterplot of latitude and longitude points. When I create a tile layer with OpenStreet map and option 'crs: L.CRS.EPSG4326', I get two errors: first of all the mapping transformation is wrong (for the tiles I get), and I get tile loading errors like ("GET http://b.tile.osm.org/2/7/0.png 404 (Not Found)".

Removing the crs option to go back to the default mapping fixes both of these. Is there some additional setting or transformation that I am missing?

Code snippet:

this.mapObj = new L.Map( plotElementIDinDOM, {
            zoomControl: false,
            dragging: false,
            touchZoom: false,
            scrollWheelZoom: false,
            doubleClickZoom: false,
            tap: false,
            crs: L.CRS.EPSG4326 // L.CRS.EPSG3857 (default)
        } );
var OSM2 = L.tileLayer( 'http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
        } );
OSM2.addTo( this.mapObj );

I am trying to map points with:

this.mapObj.latLngToContainerPoint( latLngCoords );

You need to use tiles already in the EPSG:4326 projection. Leaflet will not reproject raster tiles.

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.