kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
587 stars 172 forks source link

Possible to set origin and bounds on a tileLayer? #165

Open sweco-sekrsv opened 5 years ago

sweco-sekrsv commented 5 years ago

Hi!

I have a map with some background layers in Sweref99 18:00. I set original bound to a quite large area:

var crs = new L.Proj.CRS('EPSG:3011',
  '+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
  {
    resolutions: [
            8192, 4096, 2048, 1024, 512, 256, 128,
            64, 32, 16, 8, 4, 2, 1, 0.5, 0.25,0.125,0.0625
        ],
    bounds: L.bounds([142655.56858318162267, 6574447.45438828971237], [158799.56858318162267, 6590591.45438828971237])
  })

To the map I I want to add a TMS layer (which is also using EPSG:3011) but that has a smaller bound but it does not work.:

var options = {
    maxZoom: 17,
    maxNativeZoom: 16,
    zoomReverse: false,
    continuousWorld: true,
    tms: true,
    origin: [148499.89788831950864, 6579499.93206414766610],
    bounds: L.bounds([148499.89788831950864, 6579499.93206414766610], [154661.14788831950864, 6584500.18206414766610])
        };

var customTiles =  L.tileLayer('tms3/{z}/{x}/{y}.png', options);

Is it possible to define a bound and origin for my tileLayer?

The only way I get this working is if I set the smaller bounds and the origin on the crs but then all my background layers are cropped to the smaller bounds which is not what I'm after.