TransWikia.com

XY bounds for L.tileLayer in CRS.Simple

Geographic Information Systems Asked by Fynjy888 on December 13, 2020

Sorry for my English

I have leaflet.js (image of map 5913×7863) and there L.CRS.Simple

I had

var imageBounds = [[1468.9700,-11.7050], [1968.2705,363.7705]];
var file0 = new L.imageOverlay(imageUrl, imageBounds).addTo(map);

and everything was good, but I understood, that L.imageOverlay – it’s wrong way and I need tiles. So now I have

L.tileLayer('images/tiles/{z}/{x}/{y}.png', {
continuousWorld: true,
noWrap: true,
maxZoom: 6,
minZoom: 3 
}).addTo(map);

But I don’t know how to do L.tileLayer with this bounds (coordinates) [1468.9700,-11.7050], [1968.2705,363.7705]

Now bounds near this: [0,0], [-123,92], but I need [1468.9700,-11.7050], [1968.2705,363.7705]
And I don’t understand why is so hard to do bounds with tiles as easy with imageOverlay?

I have tried this:

var southWest = L.latLng(1468.9700,-11.7050),
northEast = L.latLng(1968.2705,363.7705),
mybounds = L.latLngBounds(southWest, northEast);
...
bounds: mybounds

but it have not helped.

Update:

I trying to resolve my problem, but it don’t help:

var w = 5913;
var h = 7863;
var mapMinZoom = 0;
var mapMaxZoom = 5;      
var _map = L.map('map', {
    maxZoom: mapMaxZoom,
    minZoom: mapMinZoom,
    crs: L.CRS.Simple,
    zoomControl: false,
    attributionControl: false,
  });

var _mapBounds = new L.LatLngBounds(
_map.unproject([0, h], mapMaxZoom),
_map.unproject([w, 0], mapMaxZoom));
_map.setMaxBounds(_mapBounds);

var _mapCenter = _map.unproject([w/2, h/2], mapMaxZoom);
_map.setView(_mapCenter, 3);


var _tileLayer = L.tileLayer('images/tiles/{z}/{x}/{y}.png', {
    minZoom: mapMinZoom, maxZoom: mapMaxZoom,
    bounds: _mapBounds,
    continuousWorld: true,
    noWrap:true,
    tileSize:256,
    crs: L.CRS.Simple,
    detectRetina:false
  }).addTo(_map);

Now coordinates is near -247,184
and unproject coordinates is near 1480,1970

If you have a solution for L.CRS.Simple and XY coordinates – please help!

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP